Part Number Hot Search : 
C1004 JAN117T TDA100 09012 UF1004 W24V04 SXXBP SAA5496
Product Description
Full Text Search
 

To Download PIC17LC42-33IL Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 PIC17C4X
High-Performance 8-Bit CMOS EPROM/ROM Microcontroller
Devices included in this data sheet:
* * * * * * PIC17CR42 PIC17C42A PIC17C43 PIC17CR43 PIC17C44 PIC17C42
Pin Diagram
PDIP, CERDIP, Windowed CERDIP
VDD RC0/AD0 RC1/AD1 RC2/AD2 RC3/AD3 RC4/AD4 RC5/AD5 RC6/AD6 RC7/AD7 VSS RB0/CAP1 RB1/CAP2 RB2/PWM1 RB3/PWM2 RB4/TCLK12 RB5/TCLK3 RB6 RB7 OSC1/CLKIN OSC2/CLKOUT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 RD0/AD8 RD1/AD9 RD2/AD10 RD3/AD11 RD4/AD12 RD5/AD13 RD6/AD14 RD7/AD15 MCLR/VPP VSS RE0/ALE RE1/OE RE2/WR TEST RA0/INT RA1/T0CKI RA2 RA3 RA4/RX/DT RA5/TX/CK
PIC17C4X
Microcontroller Core Features:
* Only 58 single word instructions to learn * All single cycle instructions (121 ns) except for program branches and table reads/writes which are two-cycle * Operating speed: - DC - 33 MHz clock input - DC - 121 ns instruction cycle Program Memory Device EPROM ROM Data Memory
B
* TMR2: 8-bit timer/counter * TMR3: 16-bit timer/counter * Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI)
B
PIC17CR42 2K 232 PIC17C42A 2K 232 PIC17C43 4K 454 PIC17CR43 4K 454 PIC17C44 8K 454 PIC17C42 2K 232 * Hardware Multiplier (Not available on the PIC17C42) * Interrupt capability * 16 levels deep hardware stack * Direct, indirect and relative addressing modes * Internal/External program memory execution * 64K x 16 addressable program memory space
Special Microcontroller Features:
* Power-on Reset (POR), Power-up Timer (PWRT) and Oscillator Start-up Timer (OST) * Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation * Code-protection * Power saving SLEEP mode * Selectable oscillator options
CMOS Technology:
* Low-power, high-speed CMOS EPROM/ROM technology * Fully static design * Wide operating voltage range (2.5V to 6.0V) * Commercial and Industrial Temperature Range * Low-power consumption - < 5 mA @ 5V, 4 MHz - 100 A typical @ 4.5V, 32 kHz - < 1 A typical standby current @ 5V
Peripheral Features:
* 33 I/O pins with individual direction control * High current sink/source for direct LED drive - RA2 and RA3 are open drain, high voltage (12V), high current (60 mA), I/O * Two capture inputs and two PWM outputs - Captures are 16-bit, max resolution 160 ns - PWM resolution is 1- to 10-bit * TMR0: 16-bit timer/counter with 8-bit programmable prescaler * TMR1: 8-bit timer/counter NOT recommended for new designs, use 17C42A.
(c) 1996 Microchip Technology Inc.
DS30412C-page 1
This document was created with FrameMaker 4 0 4
PIC17C4X
Pin Diagrams Cont.'d
RC3/AD3 RC2/AD2 RC1/AD1 RC0/AD0 NC VDD VDD RD0/AD8 RD1/AD9 RD2/AD10 RD3/AD11
PLCC
MQFP TQFP
RC4/AD4 RC5/AD5 RC6/AD6 RC7/AD7 VSS VSS RB0/CAP1 RB1/CAP2 RB2/PWM1 RB3/PWM2 RB4/TCLK12
6 5 4 3 2 1 44 43 42 41 40
7 8 9 10 11 12 13 14 15 16 17
39 38 37 36 35 34 33 32 31 30 29
RD4/AD12 RD5/AD13 RD6/AD14 RD7/AD15 MCLR/VPP VSS VSS RE0/ALE RE1/OE RE2/WR TEST
TEST RE2/WR RE1/OE RE0/ALE VSS VSS MCLR/VPP RD7/AD15 RD6/AD14 RD5/AD13 RD4/AD12
44 43 42 41 40 39 38 37 36 35 34
RA0/INT RA1/T0CKI RA2 RA3 RA4/RX/DT RA5/TX/CK OSC2/CLKOUT OSC1/CLKIN RB7 RB6 RB5/TCLK3
All devices are available in all package types, listed in Section 21.0, with the following exceptions: * ROM devices are not available in Windowed CERDIP Packages * TQFP is not available for the PIC17C42.
PIC17C4X
28 27 26 25 24 23 22 21 20 19 18 RA0/INT RA1/T0CKI RA2 RA3 RA4/RX/DT RA5/TX/CK OSC2/CLKOUT OSC1/CLKIN RB7 RB6 RB5/TCLK3
1 2 3 4 5 6 7 8 9 10 11
33 32 31 30 29 28 27 26 25 24 23
RB4/TCLK12 RB3/PWM2 RB2/PWM1 RB1/CAP2 RB0/CAP1 VSS VSS RC7/AD7 RC6/AD6 RC5/AD5 RC4/AD4
DS30412C-page 2
(c) 1996 Microchip Technology Inc.
PIC17C4X
22 21 20 19 18 17 16 15 14 13 12 RC3/AD3 RC2/AD2 RC1/AD1 RC0/AD0 NC VDD VDD RD0/AD8 RD1/AD9 RD2/AD10 RD3/AD11
PIC17C4X
Table of Contents
1.0 Overview .............................................................................................................................................................. 5 2.0 PIC17C4X Device Varieties ................................................................................................................................. 7 3.0 Architectural Overview ......................................................................................................................................... 9 4.0 Reset .................................................................................................................................................................. 15 5.0 Interrupts ............................................................................................................................................................ 21 6.0 Memory Organization ......................................................................................................................................... 29 7.0 Table Reads and Table Writes........................................................................................................................... 43 8.0 Hardware Multiplier ............................................................................................................................................ 49 9.0 I/O Ports ............................................................................................................................................................. 53 10.0 Overview of Timer Resources ............................................................................................................................ 65 11.0 Timer0 ................................................................................................................................................................ 67 12.0 Timer1, Timer2, Timer3, PWMs and Captures................................................................................................... 71 13.0 Universal Synchronous Asynchronous Receiver Transmitter (USART) Module................................................ 83 14.0 Special Features of the CPU.............................................................................................................................. 99 15.0 Instruction Set Summary .................................................................................................................................. 107 16.0 Development Support....................................................................................................................................... 143 17.0 PIC17C42 Electrical Characteristics ................................................................................................................ 147 18.0 PIC17C42 DC and AC Characteristics............................................................................................................. 163 19.0 PIC17CR42/42A/43/R43/44 Electrical Characteristics..................................................................................... 175 20.0 PIC17CR42/42A/43/R43/44 DC and AC Characteristics ................................................................................. 193 21.0 Packaging Information...................................................................................................................................... 205 Appendix A: Modifications .......................................................................................................................................... 211 Appendix B: Compatibility........................................................................................................................................... 211 Appendix C: What's New ............................................................................................................................................ 212 Appendix D: What's Changed..................................................................................................................................... 212 Appendix E: PIC16/17 Microcontrollers ...................................................................................................................... 213 Appendix F: Errata for PIC17C42 Silicon ................................................................................................................... 223 Index ............................................................................................................................................................................ 226 PIC17C4X Product Identification System .................................................................................................................... 237
For register and module descriptions in this data sheet, device legends show which devices apply to those sections. For example, the legend below shows that some features of only the PIC17C43, PIC17CR43, PIC17C44 are described in this section. Applicable Devices 42 R42 42A 43 R43 44
To Our Valued Customers
We constantly strive to improve the quality of all our products and documentation. We have spent an exceptional amount of time to ensure that these documents are correct. However, we realize that we may have missed a few things. If you find any information that is missing or appears in error from the previous version of the PIC17C4X Data Sheet (Literature Number DS30412B), please use the reader response form in the back of this data sheet to inform us. We appreciate your assistance in making this a better document. To assist you in the use of this document, Appendix C contains a list of new information in this data sheet, while Appendix D contains information that has changed
(c) 1996 Microchip Technology Inc.
DS30412C-page 3
PIC17C4X
NOTES:
DS30412C-page 4
(c) 1996 Microchip Technology Inc.
PIC17C4X
1.0 OVERVIEW
This data sheet covers the PIC17C4X group of the PIC17CXX family of microcontrollers. The following devices are discussed in this data sheet: * * * * * * PIC17C42 PIC17CR42 PIC17C42A PIC17C43 PIC17CR43 PIC17C44 power saving. The user can wake-up the chip from SLEEP through several external and internal interrupts and device resets. There are four configuration options for the device operational modes: * * * * Microprocessor Microcontroller Extended microcontroller Protected microcontroller
The PIC17CR42, PIC17C42A, PIC17C43, PIC17CR43, and PIC17C44 devices include architectural enhancements over the PIC17C42. These enhancements will be discussed throughout this data sheet. The PIC17C4X devices are 40/44-Pin, EPROM/ROM-based members of the versatile PIC17CXX family of low-cost, high-performance, CMOS, fully-static, 8-bit microcontrollers. All PIC16/17 microcontrollers employ an advanced RISC architecture. The PIC17CXX has enhanced core features, 16-level deep stack, and multiple internal and external interrupt sources. The separate instruction and data buses of the Harvard architecture allow a 16-bit wide instruction word with a separate 8-bit wide data. The two stage instruction pipeline allows all instructions to execute in a single cycle, except for program branches (which require two cycles). A total of 55 instructions (reduced instruction set) are available in the PIC17C42 and 58 instructions in all the other devices. Additionally, a large register set gives some of the architectural innovations used to achieve a very high performance. For mathematical intensive applications all devices, except the PIC17C42, have a single cycle 8 x 8 Hardware Multiplier. PIC17CXX microcontrollers typically achieve a 2:1 code compression and a 4:1 speed improvement over other 8-bit microcontrollers in their class. PIC17C4X devices have up to 454 bytes of RAM and 33 I/O pins. In addition, the PIC17C4X adds several peripheral features useful in many high performance applications including: * * * * Four timer/counters Two capture inputs Two PWM outputs A Universal Synchronous Asynchronous Receiver Transmitter (USART)
The microprocessor and extended microcontroller modes allow up to 64K-words of external program memory. A highly reliable Watchdog Timer with its own on-chip RC oscillator provides protection against software malfunction. Table 1-1 lists the features of the PIC17C4X devices. A UV-erasable CERDIP-packaged version is ideal for code development while the cost-effective One-Time Programmable (OTP) version is suitable for production in any volume. The PIC17C4X fits perfectly in applications ranging from precise motor control and industrial process control to automotive, instrumentation, and telecom applications. Other applications that require extremely fast execution of complex software programs or the flexibility of programming the software code as one of the last steps of the manufacturing process would also be well suited. The EPROM technology makes customization of application programs (with unique security codes, combinations, model numbers, parameter storage, etc.) fast and convenient. Small footprint package options make the PIC17C4X ideal for applications with space limitations that require high performance. High speed execution, powerful peripheral features, flexible I/O, and low power consumption all at low cost make the PIC17C4X ideal for a wide range of embedded control applications.
1.1
Family and Upward Compatibility
Those users familiar with the PIC16C5X and PIC16CXX families of microcontrollers will see the architectural enhancements that have been implemented. These enhancements allow the device to be more efficient in software and hardware requirements. Please refer to Appendix A for a detailed list of enhancements and modifications. Code written for PIC16C5X or PIC16CXX can be easily ported to PIC17CXX family of devices (Appendix B).
These special features reduce external components, thus reducing cost, enhancing system reliability and reducing power consumption. There are four oscillator options, of which the single pin RC oscillator provides a low-cost solution, the LF oscillator is for low frequency crystals and minimizes power consumption, XT is a standard crystal, and the EC is for external clock input. The SLEEP (power-down) mode offers additional
1.2
Development Support
The PIC17CXX family is supported by a full-featured macro assembler, a software simulator, an in-circuit emulator, a universal programmer, a "C" compiler, and fuzzy logic support tools.
(c) 1996 Microchip Technology Inc.
DS30412C-page 5
This document was created with FrameMaker 4 0 4
PIC17C4X
TABLE 1-1: PIC17CXX FAMILY OF DEVICES
PIC17C42 25 MHz 4.5 - 5.5V 2K 232 Yes Yes Yes Yes 2 2 Yes Yes Yes Yes 11 Yes 33 25 mA 25 mA(1) 40-pin DIP 44-pin PLCC 44-pin MQFP PIC17CR42 33 MHz 2.5 - 6.0V 2K 232 Yes Yes Yes Yes Yes 2 2 Yes Yes Yes Yes 11 Yes 33 25 mA 25 mA(1) 40-pin DIP 44-pin PLCC 44-pin MQFP 44-pin TQFP PIC17C42A 33 MHz 2.5 - 6.0V 2K 232 Yes Yes Yes Yes Yes 2 2 Yes Yes Yes Yes 11 Yes 33 25 mA 25 mA(1) 40-pin DIP 44-pin PLCC 44-pin MQFP 44-pin TQFP PIC17C43 33 MHz 2.5 - 6.0V 4K 454 Yes Yes Yes Yes Yes 2 2 Yes Yes Yes Yes 11 Yes 33 25 mA 25 mA(1) 40-pin DIP 44-pin PLCC 44-pin MQFP 44-pin TQFP PIC17CR43 33 MHz 2.5 - 6.0V 4K 454 Yes Yes Yes Yes Yes 2 2 Yes Yes Yes Yes 11 Yes 33 25 mA 25 mA(1) 40-pin DIP 44-pin PLCC 44-pin MQFP 44-pin TQFP PIC17C44 33 MHz 2.5 - 6.0V 8K 454 Yes Yes Yes Yes Yes 2 2 Yes Yes Yes Yes 11 Yes 33 25 mA 25 mA(1) 40-pin DIP 44-pin PLCC 44-pin MQFP 44-pin TQFP Features Maximum Frequency of Operation Operating Voltage Range Program Memory x16 (EPROM) (ROM) Data Memory (bytes) Hardware Multiplier (8 x 8) Timer0 (16-bit + 8-bit postscaler) Timer1 (8-bit) Timer2 (8-bit) Timer3 (16-bit) Capture inputs (16-bit) PWM outputs (up to 10-bit) USART/SCI Power-on Reset Watchdog Timer External Interrupts Interrupt Sources Program Memory Code Protect I/O Pins I/O High Current Capabil- Source ity Sink Package Types
Note 1:
Pins RA2 and RA3 can sink up to 60 mA.
DS30412C-page 6
(c) 1996 Microchip Technology Inc.
PIC17C4X
2.0 PIC17C4X DEVICE VARIETIES
2.3
A variety of frequency ranges and packaging options are available. Depending on application and production requirements, the proper device option can be selected using the information in the PIC17C4X Product Selection System section at the end of this data sheet. When placing orders, please use the "PIC17C4X Product Identification System" at the back of this data sheet to specify the correct part number. For the PIC17C4X family of devices, there are four device "types" as indicated in the device number: 1. C, as in PIC17C42. These devices have EPROM type memory and operate over the standard voltage range. LC, as in PIC17LC42. These devices have EPROM type memory, operate over an extended voltage range, and reduced frequency range. CR, as in PIC17CR42. These devices have ROM type memory and operate over the standard voltage range. LCR, as in PIC17LCR42. These devices have ROM type memory, operate over an extended voltage range, and reduced frequency range.
Quick-Turnaround-Production (QTP) Devices
Microchip offers a QTP Programming Service for factory production orders. This service is made available for users who choose not to program a medium to high quantity of units and whose code patterns have stabilized. The devices are identical to the OTP devices but with all EPROM locations and configuration options already programmed by the factory. Certain code and prototype verification procedures apply before production shipments are available. Please contact your local Microchip Technology sales office for more details.
2.4
2.
Serialized Quick-Turnaround Production (SQTPSM) Devices
3.
Microchip offers a unique programming service where a few user-defined locations in each device are programmed with different serial numbers. The serial numbers may be random, pseudo-random or sequential. Serial programming allows each device to have a unique number which can serve as an entry-code, password or ID number. ROM devices do not allow serialization information in the program memory space. For information on submitting ROM code, please contact your regional sales office.
4.
2.1
UV Erasable Devices
The UV erasable version, offered in CERDIP package, is optimal for prototype development and pilot programs. The UV erasable version can be erased and reprogrammed to any of the configuration modes. Microchip's PRO MATETM programmer supports programming of the PIC17C4X. Third party programmers also are available; refer to the Third Party Guide for a list of sources.
2.5
Read Only Memory (ROM) Devices
Microchip offers masked ROM versions of several of the highest volume parts, thus giving customers a low cost option for high volume, mature products. For information on submitting ROM code, please contact your regional sales office.
2.2
One-Time-Programmable (OTP) Devices
The availability of OTP devices is especially useful for customers expecting frequent code changes and updates. The OTP devices, packaged in plastic packages, permit the user to program them once. In addition to the program memory, the configuration bits must also be programmed.
(c) 1996 Microchip Technology Inc.
DS30412C-page 7
This document was created with FrameMaker 4 0 4
PIC17C4X
NOTES:
DS30412C-page 8
(c) 1996 Microchip Technology Inc.
PIC17C4X
3.0 ARCHITECTURAL OVERVIEW
The high performance of the PIC17C4X can be attributed to a number of architectural features commonly found in RISC microprocessors. To begin with, the PIC17C4X uses a modified Harvard architecture. This architecture has the program and data accessed from separate memories. So the device has a program memory bus and a data memory bus. This improves bandwidth over traditional von Neumann architecture, where program and data are fetched from the same memory (accesses over the same bus). Separating program and data memory further allows instructions to be sized differently than the 8-bit wide data word. PIC17C4X opcodes are 16-bits wide, enabling single word instructions. The full 16-bit wide program memory bus fetches a 16-bit instruction in a single cycle. A twostage pipeline overlaps fetch and execution of instructions. Consequently, all instructions execute in a single cycle (121 ns @ 33 MHz), except for program branches and two special instructions that transfer data between program and data memory. The PIC17C4X can address up to 64K x 16 of program memory space. The PIC17C42 and PIC17C42A integrate 2K x 16 of EPROM program memory on-chip, while the PIC17CR42 has 2K x 16 of ROM program memory onchip. The PIC17C43 integrates 4K x 16 of EPROM program memory, while the PIC17CR43 has 4K x 16 of ROM program memory. The PIC17C44 integrates 8K x 16 EPROM program memory. Program execution can be internal only (microcontroller or protected microcontroller mode), external only (microprocessor mode) or both (extended microcontroller mode). Extended microcontroller mode does not allow code protection. The PIC17CXX can directly or indirectly address its register files or data memory. All special function registers, including the Program Counter (PC) and Working Register (WREG), are mapped in the data memory. The PIC17CXX has an orthogonal (symmetrical) instruction set that makes it possible to carry out any operation on any register using any addressing mode. This symmetrical nature and lack of `special optimal situations' make programming with the PIC17CXX simple yet efficient. In addition, the learning curve is reduced significantly. One of the PIC17CXX family architectural enhancements from the PIC16CXX family allows two file registers to be used in some two operand instructions. This allows data to be moved directly between two registers without going through the WREG register. This increases performance and decreases program memory usage. The PIC17CXX devices contain an 8-bit ALU and working register. The ALU is a general purpose arithmetic unit. It performs arithmetic and Boolean functions between data in the working register and any register file. The ALU is 8-bits wide and capable of addition, subtraction, shift, and logical operations. Unless otherwise mentioned, arithmetic operations are two's complement in nature. The WREG register is an 8-bit working register used for ALU operations. All PIC17C4X devices (except the PIC17C42) have an 8 x 8 hardware multiplier. This multiplier generates a 16-bit result in a single cycle. Depending on the instruction executed, the ALU may affect the values of the Carry (C), Digit Carry (DC), and Zero (Z) bits in the STATUS register. The C and DC bits operate as a borrow and digit borrow out bit, respectively, in subtraction. See the SUBLW and SUBWF instructions for examples. Although the ALU does not perform signed arithmetic, the Overflow bit (OV) can be used to implement signed math. Signed arithmetic is comprised of a magnitude and a sign bit. The overflow bit indicates if the magnitude overflows and causes the sign bit to change state. Signed math can have greater than 7-bit values (magnitude), if more than one byte is used. The use of the overflow bit only operates on bit6 (MSb of magnitude) and bit7 (sign bit) of the value in the ALU. That is, the overflow bit is not useful if trying to implement signed math where the magnitude, for example, is 11-bits. If the signed math values are greater than 7-bits (15-, 24or 31-bit), the algorithm must ensure that the low order bytes ignore the overflow status bit. Care should be taken when adding and subtracting signed numbers to ensure that the correct operation is executed. Example 3-1 shows an item that must be taken into account when doing signed arithmetic on an ALU which operates as an unsigned machine.
EXAMPLE 3-1:
Hex Value FFh + 01h =?
SIGNED MATH
Signed Value Math -127 + 1 = -126 (FEh) Unsigned Value Math 255 + 1 = 0 (00h); Carry bit = 1
Signed math requires the result in REG to be FEh (-126). This would be accomplished by subtracting one as opposed to adding one. Simplified block diagrams are shown in Figure 3-1 and Figure 3-2. The descriptions of the device pins are listed in Table 3-1.
(c) 1996 Microchip Technology Inc.
DS30412C-page 9
This document was created with FrameMaker 4 0 4
IR BUS <16> 8 IR BUS <7:0> IR LATCH <16> INSTRUCTION DECODER 8 8 RAM ADDR BUFFER
FIGURE 3-1:
RB0/CAP1 RB1/CAP2 RB2/PWM1 RB2/PWM2 RB4/TCLK12 RB5/TCLK3 RB6 RB7 PCH PCL DIGITAL I/O PORTS A, B
DATA BUS <8>
DS30412C-page 10
IR BUS <16> WREG <8> READ/WRITE DECODE FOR REGISTERS MAPPED IN DATA SPACE DATA RAM 232x8 LITERAL CONTROL OUTPUTS FSR1 RDF DATA LATCH TABLE LATCH <16> ROM LATCH <16> 8 DATA BUS <8> WRF FSR0 DECODE BSR 4 3 IR <2:0> PCLATH<8> TABLE PTR<16> PROGRAM MEMORY (EPROM/ROM) 2K x 16 AD <15:0> PORTC and PORTD SYSTEM BUS INTERFACE IR <7> Timer1, Timer2, Timer3 CAPTURE PWM DATA LATCH 16 ADDRESS LATCH 11 STACK 16 x 16 16 16 SERIAL PORT INTERRUPT MODULE Timer0 MODULE Q1, Q2, Q3, Q4 OSC1, OSC2 ALE, WR, OE PORTE CONTROL SIGNALS TO CPU CHIP_RESET AND OTHER CONTROL SIGNALS CLOCK GENERATOR POWER ON RESET WATCHDOG TIMER OSC STARTUP TIMER TEST MODE SELECT VDD, VSS MCLR/VPP
PIC17C4X
BITOP
ALU
PIC17C42 BLOCK DIAGRAM
SHIFTER
PORTB
8
6
8
6
PORTA
6
2
RA0/INT RA1/T0CKI RA2 RA3 RA4/RX/DT RA5/TX/CK
RA1/ T0CKI
PERIPHERALS
RA1/T0CKI RA0/INT
(c) 1996 Microchip Technology Inc.
TEST
IR BUS <16> 12 RAM ADDR BUFFER DATA RAM INSTRUCTION DECODER 8 8 IR LATCH <16> BSR<7:4> IR BUS<7:0>
FIGURE 3-2:
IR BUS <16>
WREG <8>
BITOP
READ/WRITE DECODE FOR REGISTERS MAPPED IN DATA SPACE LITERAL CONTROL OUTPUTS FSR0 FSR1 232 x 8 PIC17CR42 232 x 8 PIC17C42A 454 x 8 PIC17C43 454 x 8 PIC17CR43 454 x 8 PIC17C44 DATA LATCH TABLE LATCH <16> ROM LATCH <16> 8 DATA BUS <8> PRODL
DATA BUS <8>
(c) 1996 Microchip Technology Inc.
DECODE 8 x 8 mult RDF WRF BSR 4 3 IR <2:0> PCLATH<8> TABLE PTR<16> PCH PCL 16 PROGRAM MEMORY (EPROM/ROM) 2K x 16 - PIC17CR42 2K x 16 - PIC17C42A 4K x 16 - PIC17C43 4K x 16 - PIC17CR43 8K x 16 - PIC17C44 ADDRESS LATCH 13 STACK 16 x 16 16 16 SERIAL PORT INTERRUPT MODULE Timer0 MODULE Q1, Q2, Q3, Q4 SYSTEM BUS INTERFACE IR <7> Timer1, Timer2, Timer3 CAPTURE PWM DATA LATCH DIGITAL I/O PORTS A, B CONTROL SIGNALS TO CPU CHIP_RESET AND OTHER CONTROL SIGNALS CLOCK GENERATOR POWER ON RESET WATCHDOG TIMER OSC STARTUP TIMER TEST MODE SELECT
ALU
SHIFTER
PRODH
PORTB
8
6
AD <15:0> PORTC and PORTD
PIC17CR42/42A/43/R43/44 BLOCK DIAGRAM
RB0/CAP1 RB1/CAP2 RB2/PWM1 RB2/PWM2 RB4/TCLK12 RB5/TCLK3 RB6 RB7
8
6
ALE, WR, OE PORTE
PORTA
6
2
OSC1, OSC2
RA0/INT RA1/T0CKI RA2 RA3 RA4/RX/DT RA5/TX/CK
VDD, VSS
RA1/ T0CKI
MCLR/VPP
PERIPHERALS
RA1/T0CKI RA0/INT
PIC17C4X
TEST
DS30412C-page 11
PIC17C4X
TABLE 3-1:
Name OSC1/CLKIN OSC2/CLKOUT
PINOUT DESCRIPTIONS
DIP No. 19 20 PLCC No. 21 22 QFP No. 37 38 I/O/P Buffer Description Type Type I O ST -- Oscillator input in crystal/resonator or RC oscillator mode. External clock input in external clock mode. Oscillator output. Connects to crystal or resonator in crystal oscillator mode. In RC oscillator or external clock modes OSC2 pin outputs CLKOUT which has one fourth the frequency of OSC1 and denotes the instruction cycle rate. Master clear (reset) input/Programming Voltage (VPP) input. This is the active low reset input to the chip. PORTA is a bi-directional I/O Port except for RA0 and RA1 which are input only. RA0/INT can also be selected as an external interrupt input. Interrupt can be configured to be on positive or negative edge. RA1/T0CKI can also be selected as an external interrupt input, and the interrupt can be configured to be on positive or negative edge. RA1/T0CKI can also be selected to be the clock input to the Timer0 timer/counter. High voltage, high current, open drain input/output port pins. High voltage, high current, open drain input/output port pins. RA4/RX/DT can also be selected as the USART (SCI) Asynchronous Receive or USART (SCI) Synchronous Data. RA5/TX/CK can also be selected as the USART (SCI) Asynchronous Transmit or USART (SCI) Synchronous Clock. PORTB is a bi-directional I/O Port with software configurable weak pull-ups. RB0/CAP1 can also be the CAP1 input pin. RB1/CAP2 can also be the CAP2 input pin. RB2/PWM1 can also be the PWM1 output pin. RB3/PWM2 can also be the PWM2 output pin. RB4/TCLK12 can also be the external clock input to Timer1 and Timer2. RB5/TCLK3 can also be the external clock input to Timer3.
MCLR/VPP
32
35
7
I/P
ST
RA0/INT
26
28
44
I
ST
RA1/T0CKI
25
27
43
I
ST
RA2 RA3 RA4/RX/DT
24 23 22
26 25 24
42 41 40
I/O I/O I/O
ST ST ST
RA5/TX/CK
21
23
39
I/O
ST
RB0/CAP1 RB1/CAP2 RB2/PWM1 RB3/PWM2 RB4/TCLK12 RB5/TCLK3 RB6 RB7
11 12 13 14 15 16 17 18
13 14 15 16 17 18 19 20
29 30 31 32 33 34 35 36
I/O I/O I/O I/O I/O I/O I/O I/O
ST ST ST ST ST ST ST ST
PORTC is a bi-directional I/O Port. RC0/AD0 2 3 19 I/O TTL This is also the lower half of the 16-bit wide system bus in microprocessor mode or extended microcontroller RC1/AD1 3 4 20 I/O TTL mode. In multiplexed system bus configuration, these RC2/AD2 4 5 21 I/O TTL pins are address output as well as data input or output. RC3/AD3 5 6 22 I/O TTL RC4/AD4 6 7 23 I/O TTL RC5/AD5 7 8 24 I/O TTL RC6/AD6 8 9 25 I/O TTL RC7/AD7 9 10 26 I/O TTL Legend: I = Input only; O = Output only; I/O = Input/Output; P = Power; -- = Not Used; TTL = TTL input; ST = Schmitt Trigger input.
DS30412C-page 12
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 3-1:
Name
PINOUT DESCRIPTIONS
DIP No. 40 39 38 37 36 35 34 33 30 PLCC No. 43 42 41 40 39 38 37 36 32 QFP No. 15 14 13 12 11 10 9 8 4 I/O/P Buffer Description Type Type I/O I/O I/O I/O I/O I/O I/O I/O I/O TTL TTL TTL TTL TTL TTL TTL TTL TTL PORTD is a bi-directional I/O Port. This is also the upper byte of the 16-bit system bus in microprocessor mode or extended microprocessor mode or extended microcontroller mode. In multiplexed system bus configuration these pins are address output as well as data input or output.
RD0/AD8 RD1/AD9 RD2/AD10 RD3/AD11 RD4/AD12 RD5/AD13 RD6/AD14 RD7/AD15 RE0/ALE
RE1/OE RE2/WR TEST VSS
29 28 27 10, 31
31 30 29
3 2 1
I/O I/O I
TTL TTL ST
11, 5, 6, P 12, 27, 28 33, 34 VDD 1 1, 44 16, 17 P Positive supply for logic and I/O pins. Legend: I = Input only; O = Output only; I/O = Input/Output; P = Power; -- = Not Used; TTL = TTL input; ST = Schmitt Trigger input.
PORTE is a bi-directional I/O Port. In microprocessor mode or extended microcontroller mode, it is the Address Latch Enable (ALE) output. Address should be latched on the falling edge of ALE output. In microprocessor or extended microcontroller mode, it is the Output Enable (OE) control output (active low). In microprocessor or extended microcontroller mode, it is the Write Enable (WR) control output (active low). Test mode selection control input. Always tie to VSS for normal operation. Ground reference for logic and I/O pins.
(c) 1996 Microchip Technology Inc.
DS30412C-page 13
PIC17C4X
3.1 Clocking Scheme/Instruction Cycle 3.2 Instruction Flow/Pipelining
The clock input (from OSC1) is internally divided by four to generate four non-overlapping quadrature clocks, namely Q1, Q2, Q3, and Q4. Internally, the program counter (PC) is incremented every Q1, and the instruction is fetched from the program memory and latched into the instruction register in Q4. The instruction is decoded and executed during the following Q1 through Q4. The clocks and instruction execution flow are shown in Figure 3-3. An "Instruction Cycle" consists of four Q cycles (Q1, Q2, Q3, and Q4). The instruction fetch and execute are pipelined such that fetch takes one instruction cycle while decode and execute takes another instruction cycle. However, due to the pipelining, each instruction effectively executes in one cycle. If an instruction causes the program counter to change (e.g. GOTO) then two cycles are required to complete the instruction (Example 3-2). A fetch cycle begins with the program counter incrementing in Q1. In the execution cycle, the fetched instruction is latched into the "Instruction Register (IR)" in cycle Q1. This instruction is then decoded and executed during the Q2, Q3, and Q4 cycles. Data memory is read during Q2 (operand read) and written during Q4 (destination write).
FIGURE 3-3:
CLOCK/INSTRUCTION CYCLE
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
OSC1 Q1 Q2 Q3 Q4 PC OSC2/CLKOUT (RC mode)
PC PC+1 PC+2 Internal phase clock
Fetch INST (PC) Execute INST (PC-1)
Fetch INST (PC+1) Execute INST (PC)
Fetch INST (PC+2) Execute INST (PC+1)
EXAMPLE 3-2:
INSTRUCTION PIPELINE FLOW
Tcy0 Tcy1 Execute 1 Fetch 2 Execute 2 Fetch 3 Execute 3 Fetch 4 Flush Fetch SUB_1 Execute SUB_1 Tcy2 Tcy3 Tcy4 Tcy5
1. MOVLW 55h 2. MOVWF PORTB 3. CALL SUB_1 4. BSF
Fetch 1
PORTA, BIT3 (Forced NOP)
5. Instruction @ address SUB_1
All instructions are single cycle, except for any program branches. These take two cycles since the fetch instruction is "flushed" from the pipeline while the new instruction is being fetched and then executed.
DS30412C-page 14
(c) 1996 Microchip Technology Inc.
PIC17C4X
4.0 RESET
4.1
The PIC17CXX differentiates between various kinds of reset: * Power-on Reset (POR) * MCLR reset during normal operation * WDT Reset (normal operation) Some registers are not affected in any reset condition; their status is unknown on POR and unchanged in any other reset. Most other registers are forced to a "reset state" on Power-on Reset (POR), on MCLR or WDT Reset and on MCLR reset during SLEEP. They are not affected by a WDT Reset during SLEEP, since this reset is viewed as the resumption of normal operation. The TO and PD bits are set or cleared differently in different reset situations as indicated in Table 4-3. These bits are used in software to determine the nature of reset. See Table 4-4 for a full description of reset states of all registers. Note: While the device is in a reset state, the internal phase clock is held in the Q1 state. Any processor mode that allows external execution will force the RE0/ALE pin as a low output and the RE1/OE and RE2/WR pins as high outputs. 4.1.1
Power-on Reset (POR), Power-up Timer (PWRT), and Oscillator Start-up Timer (OST)
POWER-ON RESET (POR)
The Power-on Reset circuit holds the device in reset until VDD is above the trip point (in the range of 1.4V 2.3V). The PIC17C42 does not produce an internal reset when VDD declines. All other devices will produce an internal reset for both rising and falling VDD. To take advantage of the POR, just tie the MCLR/VPP pin directly (or through a resistor) to VDD. This will eliminate external RC components usually needed to create Power-on Reset. A minimum rise time for VDD is required. See Electrical Specifications for details. 4.1.2 POWER-UP TIMER (PWRT)
The Power-up Timer provides a fixed 96 ms time-out (nominal) on power-up. This occurs from rising edge of the POR signal and after the first rising edge of MCLR (detected high). The Power-up Timer operates on an internal RC oscillator. The chip is kept in RESET as long as the PWRT is active. In most cases the PWRT delay allows the VDD to rise to an acceptable level. The power-up time delay will vary from chip to chip and to VDD and temperature. See DC parameters for details.
A simplified block diagram of the on-chip reset circuit is shown in Figure 4-1.
FIGURE 4-1:
SIMPLIFIED BLOCK DIAGRAM OF ON-CHIP RESET CIRCUIT
External Reset
MCLR WDT Module VDD rise detect VDD OST/PWRT Chip_Reset OST 10-bit Ripple counter OSC1 On-chip RC OSC PWRT 10-bit Ripple counter Enable PWRT R Q WDT Time_Out Reset Power_On_Reset S
Enable OST
Power_Up (Enable the PWRT timer only during Power_Up) (Power_Up + Wake_Up) (XT + LF) (Enable the OST if it is Power_Up or Wake_Up from SLEEP and OSC type is XT or LF)
This RC oscillator is shared with the WDT when not in a power-up sequence.
(c) 1996 Microchip Technology Inc.
DS30412C-page 15
This document was created with FrameMaker 4 0 4
PIC17C4X
4.1.3 OSCILLATOR START-UP TIMER (OST)
TABLE 4-1:
Oscillator Configuration
The Oscillator Start-up Timer (OST) provides a 1024 oscillator cycle (1024TOSC) delay after MCLR is detected high or a wake-up from SLEEP event occurs. The OST time-out is invoked only for XT and LF oscillator modes on a Power-on Reset or a Wake-up from SLEEP. The OST counts the oscillator pulses on the OSC1/CLKIN pin. The counter only starts incrementing after the amplitude of the signal reaches the oscillator input thresholds. This delay allows the crystal oscillator or resonator to stabilize before the device exits reset. The length of time-out is a function of the crystal/resonator frequency. 4.1.4 TIME-OUT SEQUENCE
TIME-OUT IN VARIOUS SITUATIONS
Power-up Wake up from SLEEP MCLR Reset
XT, LF
Greater of: 96 ms or 1024TOSC Greater of: 96 ms or 1024TOSC
1024TOSC
--
EC, RC
--
--
The time-out sequence begins from the first rising edge of MCLR. Table 4-3 shows the reset conditions for some special registers, while Table 4-4 shows the initialization conditions for all the registers. The shaded registers (in Table 4-4) are for all devices except the PIC17C42. In the PIC17C42, the PRODH and PRODL registers are general purpose RAM.
On power-up the time-out sequence is as follows: First the internal POR signal goes high when the POR trip point is reached. If MCLR is high, then both the OST and PWRT timers start. In general the PWRT time-out is longer, except with low frequency crystals/resonators. The total time-out also varies based on oscillator configuration. Table 4-1 shows the times that are associated with the oscillator configuration. Figure 4-2 and Figure 4-3 display these time-out sequences. If the device voltage is not within electrical specification at the end of a time-out, the MCLR/VPP pin must be held low until the voltage is within the device specification. The use of an external RC delay is sufficient for many of these applications.
TABLE 4-2:
TO
1 1 0 0
STATUS BITS AND THEIR SIGNIFICANCE
Event
PD
1 0 1 0
Power-on Reset, MCLR Reset during normal operation, or CLRWDT instruction executed MCLR Reset during SLEEP or interrupt wake-up from SLEEP WDT Reset during normal operation WDT Reset during SLEEP
In Figure 4-2, Figure 4-3 and Figure 4-4, TPWRT > TOST, as would be the case in higher frequency crystals. For lower frequency crystals, (i.e., 32 kHz) TOST would be greater.
TABLE 4-3:
RESET CONDITION FOR THE PROGRAM COUNTER AND THE CPUSTA REGISTER
Event PCH:PCL 0000h 0000h 0000h 0000h 0000h GLINTD is set GLINTD is clear PC + 1 PC + 1 (1) CPUSTA --11 11---11 11---11 10---11 01---11 00---11 10---10 10-OST Active Yes No Yes (2) No Yes (2) Yes (2) Yes (2)
Power-on Reset MCLR Reset during normal operation MCLR Reset during SLEEP WDT Reset during normal operation WDT Reset during SLEEP (3)
Interrupt wake-up from SLEEP
Legend: u = unchanged, x = unknown, - = unimplemented read as '0'. Note 1: On wake-up, this instruction is executed. The instruction at the appropriate interrupt vector is fetched and then executed. 2: The OST is only active when the Oscillator is configured for XT or LF modes. 3: The Program Counter = 0, that is the device branches to the reset vector. This is different from the mid-range devices.
DS30412C-page 16
(c) 1996 Microchip Technology Inc.
PIC17C4X
FIGURE 4-2: TIME-OUT SEQUENCE ON POWER-UP (MCLR TIED TO VDD)
VDD MCLR INTERNAL POR TPWRT PWRT TIME-OUT
TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-3:
TIME-OUT SEQUENCE ON POWER-UP (MCLR NOT TIED TO VDD)
VDD MCLR INTERNAL POR TPWRT PWRT TIME-OUT TOST
OST TIME-OUT
INTERNAL RESET
FIGURE 4-4:
SLOW RISE TIME (MCLR TIED TO VDD)
5V VDD MCLR 0V 1V
INTERNAL POR TPWRT PWRT TIME-OUT TOST OST TIME-OUT INTERNAL RESET
(c) 1996 Microchip Technology Inc.
DS30412C-page 17
PIC17C4X
FIGURE 4-5: OSCILLATOR START-UPTIME FIGURE 4-8: PIC17C42 EXTERNAL POWER-ON RESET CIRCUIT (FOR SLOW VDD POWER-UP)
VDD D R R1 MCLR TOSC1 TOST OST TIME_OUT PWRT TIME_OUT TPWRT INTERNAL RESET This figure shows in greater detail the timings involved with the oscillator start-up timer. In this example the low frequency crystal start-up time is larger than power-up time (TPWRT). Tosc1 = time for the crystal oscillator to react to an oscillation level detectable by the Oscillator Start-up Timer (ost). TOST = 1024TOSC. C PIC17C42
VDD VDD MCLR OSC2
FIGURE 4-6:
USING ON-CHIP POR
VDD VDD MCLR
Note 1: An external Power-on Reset circuit is required only if VDD power-up time is too slow. The diode D helps discharge the capacitor quickly when VDD powers down. 2: R < 40 k is recommended to ensure that the voltage drop across R does not exceed 0.2V (max. leakage current spec. on the MCLR/VPP pin is 5 A). A larger voltage drop will degrade VIH level on the MCLR/VPP pin. 3: R1 = 100 to 1 k will limit any current flowing into MCLR from external capacitor C in the event of MCLR/VPP pin breakdown due to Electrostatic Discharge (ESD) or (Electrical Overstress) EOS.
PIC17CXX
FIGURE 4-9: FIGURE 4-7: BROWN-OUT PROTECTION CIRCUIT 1
VDD
BROWN-OUT PROTECTION CIRCUIT 2
VDD
R1 VDD VDD 33k 10k 40 k MCLR PIC17CXX This brown-out circuit is less expensive, albeit less accurate. Transistor Q1 turns off when VDD is below a certain level such that: R2 Q1 MCLR 40 k PIC17CXX
This circuit will activate reset when VDD goes below (Vz + 0.7V) where Vz = Zener voltage.
VDD *
R1 R1 + R2
= 0.7V
DS30412C-page 18
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 4-4:
Register Unbanked INDF0 FSR0 PCL PCLATH ALUSTA T0STA CPUSTA(3) INTSTA INDF1 FSR1 WREG TMR0L TMR0H TBLPTRL (4) TBLPTRH (4) TBLPTRL
(5)
INITIALIZATION CONDITIONS FOR SPECIAL FUNCTION REGISTERS
Address Power-on Reset MCLR Reset WDT Reset 0000 0000 uuuu uuuu 0000h 0000 1111 0000 --11 0000 uuuu uuuu uuuu uuuu uuuu 0000 uuuu 000qq-0000 uuuu uuuu uuuu uuuu uuuu Wake-up from SLEEP through interrupt 0000 0000 uuuu uuuu PC + 1(2) uuuu uuuu 1111 uuuu 0000 000--uu qq-uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu(1) uuuu uuuu uuuu uuuu uuuu uuuu
00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 0Dh 0Eh 0Dh 0Eh 0Fh 10h 11h 12h 13h 14h 15h 16h 17h 10h 11h 12h 13h 14h 15h 16h
0000 0000 xxxx xxxx 0000h 0000 1111 0000 --11 0000 xxxx xxxx xxxx xxxx xxxx 0000 xxxx 00011-0000 xxxx xxxx xxxx xxxx xxxx
0000 0000
0000 0000
xxxx xxxx 0000 0000 0000 0000 0000 0000 0-xx 1111 xxxx 0000 xxxx 0000 xxxx xxxx 1111 xxxx 1111 xxxx ------0000 xxxx 1111 xxxx -00x xxxx --1x xxxx xxxx 1111 xxxx 1111 xxxx -111 -xxx 0010
uuuu uuuu 0000 0000 0000 0000 0000 0000 0-uu 1111 uuuu 0000 uuuu 0000 uuuu uuuu 1111 uuuu 1111 uuuu ------0000 uuuu 1111 uuuu -00u uuuu --1u uuuu uuuu 1111 uuuu 1111 uuuu -111 -uuu 0010
uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu ------uuuu uuuu uuuu -uuu uuuu --uu uuuu uuuu uuuu uuuu uuuu uuuu -uuu -uuu
TBLPTRH (5) BSR Bank 0 PORTA DDRB PORTB RCSTA RCREG TXSTA TXREG SPBRG Bank 1 DDRC PORTC DDRD PORTD DDRE PORTE PIR PIE Legend: Note 1: 2: 3: 4: 5:
uuuu uuuu(1) 17h 0000 0000 0000 0000 uuuu uuuu u = unchanged, x = unknown, - = unimplemented read as '0', q = value depends on condition. One or more bits in INTSTA, PIR will be affected (to cause wake-up). When the wake-up is due to an interrupt and the GLINTD bit is cleared, the PC is loaded with the interrupt vector. See Table 4-3 for reset value of specific condition. Only applies to the PIC17C42. Does not apply to the PIC17C42.
(c) 1996 Microchip Technology Inc.
DS30412C-page 19
PIC17C4X
TABLE 4-4:
Register Bank 2 TMR1 TMR2 TMR3L TMR3H PR1 PR2 PR3/CA1L PR3/CA1H Bank 3 PW1DCL PW2DCL PW1DCH PW2DCH CA2L CA2H TCON1 TCON2 Unbanked PRODL (5) 18h xxxx xxxx uuuu uuuu uuuu uuuu 19h xxxx xxxx uuuu uuuu uuuu uuuu PRODH (5) Legend: u = unchanged, x = unknown, - = unimplemented read as '0', q = value depends on condition. Note 1: One or more bits in INTSTA, PIR will be affected (to cause wake-up). 2: When the wake-up is due to an interrupt and the GLINTD bit is cleared, the PC is loaded with the interrupt vector. 3: See Table 4-3 for reset value of specific condition. 4: Only applies to the PIC17C42. 5: Does not apply to the PIC17C42.
INITIALIZATION CONDITIONS FOR SPECIAL FUNCTION REGISTERS
Address Power-on Reset MCLR Reset WDT Reset uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uu-uu-uuuu uuuu uuuu uuuu 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu ------uuuu uuuu uuuu uuuu 0000 0000
(Cont.'d)
Wake-up from SLEEP through interrupt uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uu-uu-uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu ------uuuu uuuu uuuu uuuu uuuu uuuu
10h 11h 12h 13h 14h 15h 16h 17h 10h 11h 12h 13h 14h 15h 16h 17h
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xx-xx-xxxx xxxx xxxx xxxx 0000 0000
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx ------xxxx xxxx xxxx xxxx 0000 0000
DS30412C-page 20
(c) 1996 Microchip Technology Inc.
PIC17C4X
5.0
* * * * * * * * * * *
INTERRUPTS
The PIC17C4X devices have 11 sources of interrupt: External interrupt from the RA0/INT pin Change on RB7:RB0 pins TMR0 Overflow TMR1 Overflow TMR2 Overflow TMR3 Overflow USART Transmit buffer empty USART Receive buffer full Capture1 Capture2 T0CKI edge occurred
When an interrupt is responded to, the GLINTD bit is automatically set to disable any further interrupt, the return address is pushed onto the stack and the PC is loaded with the interrupt vector address. There are four interrupt vectors. Each vector address is for a specific interrupt source (except the peripheral interrupts which have the same vector address). These sources are: * * * * External interrupt from the RA0/INT pin TMR0 Overflow T0CKI edge occurred Any peripheral interrupt
There are four registers used in the control and status of interrupts. These are: * * * * CPUSTA INTSTA PIE PIR
The CPUSTA register contains the GLINTD bit. This is the Global Interrupt Disable bit. When this bit is set, all interrupts are disabled. This bit is part of the controller core functionality and is described in the Memory Organization section.
When program execution vectors to one of these interrupt vector addresses (except for the peripheral interrupt address), the interrupt flag bit is automatically cleared. Vectoring to the peripheral interrupt vector address does not automatically clear the source of the interrupt. In the peripheral interrupt service routine, the source(s) of the interrupt can be determined by testing the interrupt flag bits. The interrupt flag bit(s) must be cleared in software before re-enabling interrupts to avoid infinite interrupt requests. All of the individual interrupt flag bits will be set regardless of the status of their corresponding mask bit or the GLINTD bit. For external interrupt events, there will be an interrupt latency. For two cycle instructions, the latency could be one instruction cycle longer. The "return from interrupt" instruction, RETFIE, can be used to mark the end of the interrupt service routine. When this instruction is executed, the stack is "POPed", and the GLINTD bit is cleared (to re-enable interrupts).
FIGURE 5-1:
TMR1IF TMR1IE
INTERRUPT LOGIC
TMR2IF TMR2IE TMR3IF TMR3IE CA1IF CA1IE CA2IF CA2IE TXIF TXIE RCIF RCIE RBIF RBIE
T0IF T0IE INTF INTE T0CKIF T0CKIE PEIF PEIE GLINTD
Wake-up (If in SLEEP mode) or terminate long write
Interrupt to CPU
(c) 1996 Microchip Technology Inc.
DS30412C-page 21
This document was created with FrameMaker 4 0 4
PIC17C4X
5.1 Interrupt Status Register (INTSTA)
The Interrupt Status/Control register (INTSTA) records the individual interrupt requests in flag bits, and contains the individual interrupt enable bits (not for the peripherals). The PEIF bit is a read only, bit wise OR of all the peripheral flag bits in the PIR register (Figure 5-4). T0IF, INTF, T0CKIF, or PEIF will be set by the specified condition, even if the corresponding interrupt enable bit is clear (interrupt disabled) or the GLINTD bit is set (all interrupts disabled). Care should be taken when clearing any of the INTSTA register enable bits when interrupts are enabled (GLINTD is clear). If any of the INTSTA flag bits (T0IF, INTF, T0CKIF, or PEIF) are set in the same instruction cycle as the corresponding interrupt enable bit is cleared, the device will vector to the reset address (0x00). When disabling any of the INTSTA enable bits, the GLINTD bit should be set (disabled). Note:
FIGURE 5-2: INTSTA REGISTER (ADDRESS: 07h, UNBANKED)
R-0 PEIF bit7 bit 7: R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 T0CKIF T0IF INTF PEIE T0CKIE T0IE INTE bit0
R = Readable bit W = Writable bit - n = Value at POR reset
PEIF: Peripheral Interrupt Flag bit This bit is the OR of all peripheral interrupt flag bits AND'ed with their corresponding enable bits. 1 = A peripheral interrupt is pending 0 = No peripheral interrupt is pending T0CKIF: External Interrupt on T0CKI Pin Flag bit This bit is cleared by hardware, when the interrupt logic forces program execution to vector (18h). 1 = The software specified edge occurred on the RA1/T0CKI pin 0 = The software specified edge did not occur on the RA1/T0CKI pin T0IF: TMR0 Overflow Interrupt Flag bit This bit is cleared by hardware, when the interrupt logic forces program execution to vector (10h). 1 = TMR0 overflowed 0 = TMR0 did not overflow INTF: External Interrupt on INT Pin Flag bit This bit is cleared by hardware, when the interrupt logic forces program execution to vector (08h). 1 = The software specified edge occurred on the RA0/INT pin 0 = The software specified edge did not occur on the RA0/INT pin PEIE: Peripheral Interrupt Enable bit This bit enables all peripheral interrupts that have their corresponding enable bits set. 1 = Enable peripheral interrupts 0 = Disable peripheral interrupts T0CKIE: External Interrupt on T0CKI Pin Enable bit 1 = Enable software specified edge interrupt on the RA1/T0CKI pin 0 = Disable interrupt on the RA1/T0CKI pin T0IE: TMR0 Overflow Interrupt Enable bit 1 = Enable TMR0 overflow interrupt 0 = Disable TMR0 overflow interrupt INTE: External Interrupt on RA0/INT Pin Enable bit 1 = Enable software specified edge interrupt on the RA0/INT pin 0 = Disable software specified edge interrupt on the RA0/INT pin
bit 6:
bit 5:
bit 4:
bit 3:
bit 2:
bit 1:
bit 0:
DS30412C-page 22
(c) 1996 Microchip Technology Inc.
PIC17C4X
5.2 Peripheral Interrupt Enable Register (PIE)
This register contains the individual flag bits for the Peripheral interrupts.
FIGURE 5-3: PIE REGISTER (ADDRESS: 17h, BANK 1)
R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 RBIE TMR3IE TMR2IE TMR1IE CA2IE CA1IE TXIE RCIE bit7 bit0 bit 7: RBIE: PORTB Interrupt on Change Enable bit 1 = Enable PORTB interrupt on change 0 = Disable PORTB interrupt on change TMR3IE: Timer3 Interrupt Enable bit 1 = Enable Timer3 interrupt 0 = Disable Timer3 interrupt TMR2IE: Timer2 Interrupt Enable bit 1 = Enable Timer2 interrupt 0 = Disable Timer2 interrupt TMR1IE: Timer1 Interrupt Enable bit 1 = Enable Timer1 interrupt 0 = Disable Timer1 interrupt CA2IE: Capture2 Interrupt Enable bit 1 = Enable Capture interrupt on RB1/CAP2 pin 0 = Disable Capture interrupt on RB1/CAP2 pin CA1IE: Capture1 Interrupt Enable bit 1 = Enable Capture interrupt on RB2/CAP1 pin 0 = Disable Capture interrupt on RB2/CAP1 pin TXIE: USART Transmit Interrupt Enable bit 1 = Enable Transmit buffer empty interrupt 0 = Disable Transmit buffer empty interrupt RCIE: USART Receive Interrupt Enable bit 1 = Enable Receive buffer full interrupt 0 = Disable Receive buffer full interrupt
R = Readable bit W = Writable bit -n = Value at POR reset
bit 6:
bit 5:
bit 4:
bit 3:
bit 2:
bit 1:
bit 0:
(c) 1996 Microchip Technology Inc.
DS30412C-page 23
PIC17C4X
5.3 Peripheral Interrupt Request Register (PIR)
Note: These bits will be set by the specified condition, even if the corresponding interrupt enable bit is cleared (interrupt disabled), or the GLINTD bit is set (all interrupts disabled). Before enabling an interrupt, the user may wish to clear the interrupt flag to ensure that the program does not immediately branch to the peripheral interrupt service routine.
This register contains the individual flag bits for the peripheral interrupts.
FIGURE 5-4: PIR REGISTER (ADDRESS: 16h, BANK 1)
R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 RBIF TMR3IF TMR2IF TMR1IF CA2IF CA1IF bit7 bit 7: R-1 TXIF R-0 RCIF bit0
R = Readable bit W = Writable bit -n = Value at POR reset
RBIF: PORTB Interrupt on Change Flag bit 1 = One of the PORTB inputs changed (Software must end the mismatch condition) 0 = None of the PORTB inputs have changed TMR3IF: Timer3 Interrupt Flag bit If Capture1 is enabled (CA1/PR3 = 1) 1 = Timer3 overflowed 0 = Timer3 did not overflow If Capture1 is disabled (CA1/PR3 = 0) 1 = Timer3 value has rolled over to 0000h from equalling the period register (PR3H:PR3L) value 0 = Timer3 value has not rolled over to 0000h from equalling the period register (PR3H:PR3L) value
bit 6:
bit 5:
TMR2IF: Timer2 Interrupt Flag bit 1 = Timer2 value has rolled over to 0000h from equalling the period register (PR2) value 0 = Timer2 value has not rolled over to 0000h from equalling the period register (PR2) value TMR1IF: Timer1 Interrupt Flag bit If Timer1 is in 8-bit mode (T16 = 0) 1 = Timer1 value has rolled over to 0000h from equalling the period register (PR) value 0 = Timer1 value has not rolled over to 0000h from equalling the period register (PR2) value If Timer1 is in 16-bit mode (T16 = 1) 1 = TMR1:TMR2 value has rolled over to 0000h from equalling the period register (PR1:PR2) value 0 = TMR1:TMR2 value has not rolled over to 0000h from equalling the period register (PR1:PR2) value
bit 4:
bit 3:
CA2IF: Capture2 Interrupt Flag bit 1 = Capture event occurred on RB1/CAP2 pin 0 = Capture event did not occur on RB1/CAP2 pin CA1IF: Capture1 Interrupt Flag bit 1 = Capture event occurred on RB0/CAP1 pin 0 = Capture event did not occur on RB0/CAP1 pin TXIF: USART Transmit Interrupt Flag bit 1 = Transmit buffer is empty 0 = Transmit buffer is full RCIF: USART Receive Interrupt Flag bit 1 = Receive buffer is full 0 = Receive buffer is empty
bit 2:
bit 1:
bit 0:
DS30412C-page 24
(c) 1996 Microchip Technology Inc.
PIC17C4X
5.4 Interrupt Operation
Global Interrupt Disable bit, GLINTD (CPUSTA<4>), enables all unmasked interrupts (if clear) or disables all interrupts (if set). Individual interrupts can be disabled through their corresponding enable bits in the INTSTA register. Peripheral interrupts need either the global peripheral enable PEIE bit disabled, or the specific peripheral enable bit disabled. Disabling the peripherals via the global peripheral enable bit, disables all peripheral interrupts. GLINTD is set on reset (interrupts disabled). The RETFIE instruction allows returning from interrupt and re-enable interrupts at the same time. When an interrupt is responded to, the GLINTD bit is automatically set to disable any further interrupt, the return address is pushed onto the stack and the PC is loaded with interrupt vector. There are four interrupt vectors to reduce interrupt latency. The peripheral interrupt vector has multiple interrupt sources. Once in the peripheral interrupt service routine, the source(s) of the interrupt can be determined by polling the interrupt flag bits. The peripheral interrupt flag bit(s) must be cleared in software before reenabling interrupts to avoid continuous interrupts. The PIC17C4X devices have four interrupt vectors. These vectors and their hardware priority are shown in Table 5-1. If two enabled interrupts occur "at the same time", the interrupt of the highest priority will be serviced first. This means that the vector address of that interrupt will be loaded into the program counter (PC). Note 1: Individual interrupt flag bits are set regardless of the status of their corresponding mask bit or the GLINTD bit. Note 2: When disabling any of the INTSTA enable bits, the GLINTD bit should be set (disabled). Note 3: For the PIC17C42 only: If an interrupt occurs while the Global Interrupt Disable (GLINTD) bit is being set, the GLINTD bit may unintentionally be reenabled by the user's Interrupt Service Routine (the RETFIE instruction). The events that would cause this to occur are: 1. An interrupt occurs simultaneously with an instruction that sets the GLINTD bit. The program branches to the Interrupt vector and executes the Interrupt Service Routine. The Interrupt Service Routine completes with the execution of the RETFIE instruction. This causes the GLINTD bit to be cleared (enables interrupts), and the program returns to the instruction after the one which was meant to disable interrupts.
2.
3.
The method to ensure that interrupts are globally disabled is: 1. Ensure that the GLINTD bit was set by the instruction, as shown in the following code:
CPUSTA, GLINTD ; ; CPUSTA, GLINTD ; ; LOOP ; ; ; ; Disable Global Interrupt Global Interrupt Disabled? NO, try again YES, continue with program low
TABLE 5-1:
Address 0008h 0010h 0018h 0020h
INTERRUPT VECTORS/ PRIORITIES
Vector Priority 1 (Highest) 2 3 4 (Lowest)
LOOP
BSF BTFSS GOTO
External Interrupt on RA0/ INT pin (INTF) TMR0 overflow interrupt (T0IF) External Interrupt on T0CKI (T0CKIF) Peripherals (PEIF)
(c) 1996 Microchip Technology Inc.
DS30412C-page 25
PIC17C4X
5.5 RA0/INT Interrupt 5.7 T0CKI Interrupt
The external interrupt on the RA0/INT pin is edge triggered. Either the rising edge, if INTEDG bit (T0STA<7>) is set, or the falling edge, if INTEDG bit is clear. When a valid edge appears on the RA0/INT pin, the INTF bit (INTSTA<4>) is set. This interrupt can be disabled by clearing the INTE control bit (INTSTA<0>). The INT interrupt can wake the processor from SLEEP. See Section 14.4 for details on SLEEP operation. The external interrupt on the RA1/T0CKI pin is edge triggered. Either the rising edge, if the T0SE bit (T0STA<6>) is set, or the falling edge, if the T0SE bit is clear. When a valid edge appears on the RA1/T0CKI pin, the T0CKIF bit (INTSTA<6>) is set. This interrupt can be disabled by clearing the T0CKIE control bit (INTSTA<2>). The T0CKI interrupt can wake up the processor from SLEEP. See Section 14.4 for details on SLEEP operation.
5.6
TMR0 Interrupt
An overflow (FFFFh 0000h) in TMR0 will set the T0IF (INTSTA<5>) bit. The interrupt can be enabled/ disabled by setting/clearing the T0IE control bit (INTSTA<1>). For operation of the Timer0 module, see Section 11.0.
5.8
Peripheral Interrupt
The peripheral interrupt flag indicates that at least one of the peripheral interrupts occurred (PEIF is set). The PEIF bit is a read only bit, and is a bit wise OR of all the flag bits in the PIR register AND'ed with the corresponding enable bits in the PIE register. Some of the peripheral interrupts can wake the processor from SLEEP. See Section 14.4 for details on SLEEP operation.
FIGURE 5-5:
INT PIN / T0CKI PIN INTERRUPT TIMING
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 OSC1 OSC2 RA0/INT or RA1/T0CKI INTF or T0CKIF GLINTD PC System Bus Instruction Fetched Instruction executed
PC PC + 1 Addr (Vector)
YY
Addr
YY + 1
Addr
PC + 1
PC
Inst (PC)
Addr
Inst (PC+1)
Addr
Inst (PC+1)
Addr
Inst (Vector)
RETFIE
Inst (YY + 1)
Inst (PC)
Dummy
Dummy
RETFIE
Dummy
DS30412C-page 26
(c) 1996 Microchip Technology Inc.
PIC17C4X
5.9 Context Saving During Interrupts
During an interrupt, only the returned PC value is saved on the stack. Typically, users may wish to save key registers during an interrupt; e.g. WREG, ALUSTA and the BSR registers. This requires implementation in software. Example 5-1 shows the saving and restoring of information for an interrupt service routine. The PUSH and POP routines could either be in each interrupt service routine or could be subroutines that were called. Depending on the application, other registers may also need to be saved, such as PCLATH.
EXAMPLE 5-1:
SAVING STATUS AND WREG IN RAM
; ; The addresses that are used to store the CPUSTA and WREG values ; must be in the data memory address range of 18h - 1Fh. Up to ; 8 locations can be saved and restored using ; the MOVFP instruction. This instruction neither affects the status ; bits, nor corrupts the WREG register. ; ; PUSH MOVFP WREG, TEMP_W ; Save WREG MOVFP ALUSTA, TEMP_STATUS ; Save ALUSTA MOVFP BSR, TEMP_BSR ; Save BSR ISR POP : : MOVFP MOVFP MOVFP RETFIE ; This is the interrupt service routine TEMP_W, WREG TEMP_STATUS, ALUSTA TEMP_BSR, BSR ; ; ; ; Restore WREG Restore ALUSTA Restore BSR Return from Interrupts enabled
(c) 1996 Microchip Technology Inc.
DS30412C-page 27
PIC17C4X
NOTES:
DS30412C-page 28
(c) 1996 Microchip Technology Inc.
PIC17C4X
6.0 MEMORY ORGANIZATION
FIGURE 6-1:
There are two memory blocks in the PIC17C4X; program memory and data memory. Each block has its own bus, so that access to each block can occur during the same oscillator cycle. The data memory can further be broken down into General Purpose RAM and the Special Function Registers (SFRs). The operation of the SFRs that control the "core" are described here. The SFRs used to control the peripheral modules are described in the section discussing each individual peripheral module.
PROGRAM MEMORY MAP AND STACK
PC<15:0> 16 CALL, RETURN RETFIE, RETLW Stack Level 1
* * *
Stack Level 16 Reset Vector INT Pin Interrupt Vector Timer0 Interrupt Vector T0CKI Pin Interrupt Vector Peripheral Interrupt Vector
0000h 0008h 0010h 0018h 0020h 0021h
6.1
Program Memory Organization
PIC17C4X devices have a 16-bit program counter capable of addressing a 64K x 16 program memory space. The reset vector is at 0000h and the interrupt vectors are at 0008h, 0010h, 0018h, and 0020h (Figure 6-1).
User Memory Space (1)
6.1.1
PROGRAM MEMORY OPERATION
7FFh (PIC17C42, PIC17CR42, PIC17C42A) FFFh (PIC17C43 PIC17CR43)
The PIC17C4X can operate in one of four possible program memory configurations. The configuration is selected by two configuration bits. The possible modes are: * * * * Microprocessor Microcontroller Extended Microcontroller Protected Microcontroller
1FFFh (PIC17C44)
Configuration Memory Space
The microcontroller and protected microcontroller modes only allow internal execution. Any access beyond the program memory reads unknown data. The protected microcontroller mode also enables the code protection feature. The extended microcontroller mode accesses both the internal program memory as well as external program memory. Execution automatically switches between internal and external memory. The 16-bits of address allow a program memory range of 64K-words. The microprocessor mode only accesses the external program memory. The on-chip program memory is ignored. The 16-bits of address allow a program memory range of 64K-words. Microprocessor mode is the default mode of an unprogrammed device. The different modes allow different access to the configuration bits, test memory, and boot ROM. Table 6-1 lists which modes can access which areas in memory. Test Memory and Boot Memory are not required for normal operation of the device. Care should be taken to ensure that no unintended branches occur to these areas.
FOSC0 FOSC1 WDTPS0 WDTPS1 PM0 Reserved PM1 Reserved Reserved PM2(2) Test EPROM Boot ROM
FDFFh FE00h FE01h FE02h FE03h FE04h FE05h FE06h FE07h FE08h FE0Eh FE0Fh FE10h FF5Fh FF60h FFFFh
Note 1:
User memory space may be internal, external, or both. The memory configuration depends on the processor mode. 2: This location is reserved on the PIC17C42.
(c) 1996 Microchip Technology Inc.
DS30412C-page 29
This document was created with FrameMaker 4 0 4
PIC17C4X
TABLE 6-1:
Operating Mode Microprocessor Microcontroller Extended Microcontroller Protected Microcontroller
MODE MEMORY ACCESS
Internal Program Memory No Access Access Access Configuration Bits, Test Memory, Boot ROM No Access Access No Access
The PIC17C4X can operate in modes where the program memory is off-chip. They are the microprocessor and extended microcontroller modes. The microprocessor mode is the default for an unprogrammed device. Regardless of the processor mode, data memory is always on-chip.
Access
Access
FIGURE 6-2:
MEMORY MAP IN DIFFERENT MODES
Microprocessor Mode Extended Microcontroller Mode 0000h On-chip Program Memory Microcontroller Modes 0000h On-chip Program Memory PROGRAM SPACE ON-CHIP 00h FFh OFF-CHIP 0000h On-chip Program Memory On-chip Program Memory ON-CHIP DATA SPACE DATA SPACE PROGRAM SPACE ON-CHIP 00h 120h FFh OFF-CHIP 1FFh ON-CHIP OFF-CHIP FFh 120h 1FFh ON-CHIP
PIC17C42, PIC17CR42, PIC17C42A
0000h
07FFh External Program Memory 0800h
07FFh 0800h
External Program Memory FFFFh FFFFh OFF-CHIP ON-CHIP 00h FFh OFF-CHIP ON-CHIP OFF-CHIP 0000h OFF-CHIP ON-CHIP 00h FFh ON-CHIP OFF-CHIP FE00h Config. Bits Test Memory FFFFh Boot ROM
PIC17C43, PIC17CR43, PIC17C44
0000h
0FFFh/1FFFh External Program Memory 1000h/ 2000h External Program Memory FFFFh FFFFh OFF-CHIP 00h 120h FFh OFF-CHIP 1FFh ON-CHIP ON-CHIP OFF-CHIP 00h
0FFFh/1FFFh 1000h/2000h
FE00h Config. Bits Test Memory FFFFh Boot ROM ON-CHIP OFF-CHIP
DS30412C-page 30
(c) 1996 Microchip Technology Inc.
PIC17C4X
6.1.2 EXTERNAL MEMORY INTERFACE When either microprocessor or extended microcontroller mode is selected, PORTC, PORTD and PORTE are configured as the system bus. PORTC and PORTD are the multiplexed address/data bus and PORTE is for the control signals. External components are needed to demultiplex the address and data. This can be done as shown in Figure 6-4. The waveforms of address and data are shown in Figure 6-3. For complete timings, please refer to the electrical specification section. In extended microcontroller mode, when the device is executing out of internal memory, the control signals will continue to be active. That is, they indicate the action that is occurring in the internal memory. The external memory access is ignored. This following selection is for use with Microchip EPROMs. For interfacing to other manufacturers memory, please refer to the electrical specifications of the desired PIC17C4X device, as well as the desired memory device to ensure compatibility.
FIGURE 6-3:
EXTERNAL PROGRAM MEMORY ACCESS WAVEFORMS
Q3 Q4 Q1 Q2 Q3 Q4 Q1
TABLE 6-2:
EPROM MEMORY ACCESS TIME ORDERING SUFFIX
EPROM Suffix
Q1 AD <15:0> ALE OE WR '1'
Q2
Address out Data in
Address out
Data out
PIC17C4X Instruction Oscillator Cycle Frequency Time (TCY) 8 MHz 500 ns 250 ns 200 ns 160 ns 121 ns
PIC17C42 -25 -12 -90 N.A. N.A.
PIC17C43 PIC17C44 -25 -15 -10 -70 (1)
Read cycle
Write cycle
16 MHz 20 MHz
The system bus requires that there is no bus conflict (minimal leakage), so the output value (address) will be capacitively held at the desired value. As the speed of the processor increases, external EPROM memory with faster access time must be used. Table 6-2 lists external memory speed requirements for a given PIC17C4X device frequency.
25 MHz 33 MHz
Note 1: The access times for this requires the use of fast SRAMS.
Note:
The external memory interface is not supported for the LC devices.
FIGURE 6-4:
TYPICAL EXTERNAL PROGRAM MEMORY CONNECTION DIAGRAM
AD15-AD0
A15-A0 AD7-AD0 PIC17C4X 373
Memory (MSB) Ax-A0 D7-D0 CE OE WR (2)
Memory (LSB) Ax-A0 D7-D0 CE OE WR(2)
AD15-AD8 373 ALE 138(1) I/O
(1)
OE WR Note 1: Use of I/O pins is only required for paged memory. 2: This signal is unused for ROM and EPROM devices.
(c) 1996 Microchip Technology Inc.
DS30412C-page 31
PIC17C4X
6.2 Data Memory Organization
6.2.1 GENERAL PURPOSE REGISTER (GPR) Data memory is partitioned into two areas. The first is the General Purpose Registers (GPR) area, while the second is the Special Function Registers (SFR) area. The SFRs control the operation of the device. Portions of data memory are banked, this is for both areas. The GPR area is banked to allow greater than 232 bytes of general purpose RAM. SFRs are for the registers that control the peripheral functions. Banking requires the use of control bits for bank selection. These control bits are located in the Bank Select Register (BSR). If an access is made to a location outside this banked region, the BSR bits are ignored. Figure 6-5 shows the data memory map organization for the PIC17C42 and Figure 6-6 for all of the other PIC17C4X devices. Instructions MOVPF and MOVFP provide the means to move values from the peripheral area ("P") to any location in the register file ("F"), and vice-versa. The definition of the "P" range is from 0h to 1Fh, while the "F" range is 0h to FFh. The "P" range has six more locations than peripheral registers (eight locations for the PIC17C42 device) which can be used as General Purpose Registers. This can be useful in some applications where variables need to be copied to other locations in the general purpose RAM (such as saving status information during an interrupt). The entire data memory can be accessed either directly or indirectly through file select registers FSR0 and FSR1 (Section 6.4). Indirect addressing uses the appropriate control bits of the BSR for accesses into the banked areas of data memory. The BSR is explained in greater detail in Section 6.8. All devices have some amount of GPR area. The GPRs are 8-bits wide. When the GPR area is greater than 232, it must be banked to allow access to the additional memory space. Only the PIC17C43 and PIC17C44 devices have banked memory in the GPR area. To facilitate switching between these banks, the MOVLR bank instruction has been added to the instruction set. GPRs are not initialized by a Power-on Reset and are unchanged on all other resets. 6.2.2 SPECIAL FUNCTION REGISTERS (SFR)
The SFRs are used by the CPU and peripheral functions to control the operation of the device (Figure 6-5 and Figure 6-6). These registers are static RAM. The SFRs can be classified into two sets, those associated with the "core" function and those related to the peripheral functions. Those registers related to the "core" are described here, while those related to a peripheral feature are described in the section for each peripheral feature. The peripheral registers are in the banked portion of memory, while the core registers are in the unbanked region. To facilitate switching between the peripheral banks, the MOVLB bank instruction has been provided.
DS30412C-page 32
(c) 1996 Microchip Technology Inc.
PIC17C4X
FIGURE 6-5: PIC17C42 REGISTER FILE MAP FIGURE 6-6: PIC17CR42/42A/43/R43/44 REGISTER FILE MAP
Addr Unbanked 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 0Dh 0Eh 0Fh 10h 11h 12h 13h 14h 15h 16h 17h 18h 1Fh 20h
INDF0 FSR0 PCL PCLATH ALUSTA T0STA CPUSTA INTSTA INDF1 FSR1 WREG TMR0L TMR0H TBLPTRL TBLPTRH BSR
(1) (1) (1)
Addr Unbanked 00h 01h 02h 03h 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 0Dh 0Eh 0Fh Bank 1 Bank 2
TMR1 TMR2 TMR3L TMR3H PR1 PR2 PR3L/CA1L PR3H/CA1H INDF0 FSR0 PCL PCLATH ALUSTA T0STA CPUSTA INTSTA INDF1 FSR1 WREG TMR0L TMR0H TBLPTRL TBLPTRH BSR
Bank 0
PORTA DDRB PORTB RCSTA RCREG TXSTA TXREG SPBRG
Bank 3
Bank 0 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 1Ah 1Fh 20h
PORTA DDRB PORTB RCSTA RCREG TXSTA TXREG SPBRG PRODL PRODH
Bank 1 (1)
DDRC PORTC DDRD PORTD DDRE PORTE PIR PIE
Bank 2 (1) Bank 3 (1)
TMR1 TMR2 TMR3L TMR3H PR1 PR2 PR3L/CA1L PR3H/CA1H PW1DCL PW2DCL PW1DCH PW2DCH CA2L CA2H TCON1 TCON2
DDRC PORTC DDRD PORTD DDRE PORTE PIR PIE
PW1DCL PW2DCL PW1DCH PW2DCH CA2L CA2H TCON1 TCON2
General Purpose RAM
General Purpose RAM (2)
General Purpose RAM (2)
FFh Note 1: SFR file locations 10h - 17h are banked. All other SFRs ignore the Bank Select Register (BSR) bits.
FFh Note 1: SFR file locations 10h - 17h are banked. All other SFRs ignore the Bank Select Register (BSR) bits. 2: General Purpose Registers (GPR) locations 20h - FFh and 120h - 1FFh are banked. All other GPRs ignore the Bank Select Register (BSR) bits.
(c) 1996 Microchip Technology Inc.
DS30412C-page 33
PIC17C4X
TABLE 6-3: SPECIAL FUNCTION REGISTERS
Value on Power-on Reset Value on all other resets (3)
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Unbanked 00h 01h 02h 03h(1) 04h 05h 06h 07h 08h 09h 0Ah 0Bh 0Ch 0Dh 0Eh 0Fh Bank 0 10h 11h 12h 13h 14h 15h 16h 17h Bank 1 10h 11h 12h 13h 14h 15h 16h 17h Legend: Note 1: 2: 3: 4: DDRC PORTC DDRD PORTD DDRE PORTE PIR PIE Data direction register for PORTC RC7/ AD7 RC6/ AD6 RC5/ AD5 RC4/ AD4 RC3/ AD3 RC2/ AD2 RC1/ AD1 RC0/ AD0 1111 1111 xxxx xxxx 1111 1111 RD4/ AD12 RD3/ AD11 RD2/ AD10 RD1/ AD9 RD0/ AD8 xxxx xxxx ---- -111 -- TMR1IF TMR1IE -- CA2IF CA2IE RE2/WR CA1IF CA1IE RE1/OE TXIF TXIE RE0/ALE RCIF RCIE ---- -xxx 0000 0010 0000 0000 1111 1111 uuuu uuuu 1111 1111 uuuu uuuu ---- -111 ---- -uuu 0000 0010 0000 0000 PORTA DDRB PORTB RCSTA RCREG TXSTA TXREG SPBRG RBPU -- RA5 RA4 RA3 RA2 RA1/T0CKI RA0/INT 0-xx xxxx 1111 1111 xxxx xxxx SREN CREN -- FERR OERR RX9D 0000 -00x xxxx xxxx SYNC -- -- TRMT TX9D 0000 --1x xxxx xxxx xxxx xxxx 0-uu uuuu 1111 1111 uuuu uuuu 0000 -00u uuuu uuuu 0000 --1u uuuu uuuu uuuu uuuu
(2)
INDF0 FSR0 PCL PCLATH ALUSTA T0STA CPUSTA INTSTA INDF1 FSR1 WREG TMR0L TMR0H TBLPTRL TBLPTRH BSR
Uses contents of FSR0 to address data memory (not a physical register) Indirect data memory address pointer 0 Low order 8-bits of PC Holding register for upper 8-bits of PC FS3 INTEDG -- PEIF FS2 T0SE -- T0CKIF FS1 T0CS STKAV T0IF FS0 PS3 GLINTD INTF OV PS2 TO PEIE Z PS1 PD T0CKIE DC PS0 -- T0IE C -- -- INTE
---- ---xxxx xxxx 0000 0000 0000 0000 1111 xxxx 0000 000--11 11-0000 0000 ---- ---xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx (4) (4) 0000 0000
---- ---uuuu uuuu 0000 0000 uuuu uuuu 1111 uuuu 0000 000--11 qq-0000 0000 ---- ---uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu (4) (4) 0000 0000
Uses contents of FSR1 to address data memory (not a physical register) Indirect data memory address pointer 1 Working register TMR0 register; low byte TMR0 register; high byte Low byte of program memory table pointer High byte of program memory table pointer Bank select register
Data direction register for PORTB PORTB data latch SPEN RX9
Serial port receive register CSRC TX9 TXEN
Serial port transmit register Baud rate generator register
Data direction register for PORTD RD7/ AD15 RD6/ AD14 RD5/ AD13
Data direction register for PORTE -- RBIF RBIE -- TMR3IF TMR3IE -- TMR2IF TMR2IE
5:
x = unknown, u = unchanged, - = unimplemented read as '0', q - value depends on condition. Shaded cells are unimplemented, read as '0'. The upper byte of the program counter is not directly accessible. PCLATH is a holding register for PC<15:8> whose contents are updated from or transferred to the upper byte of the program counter. The TO and PD status bits in CPUSTA are not affected by a MCLR reset. Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset. The following values are for both TBLPTRL and TBLPTRH: All PIC17C4X devices (Power-on Reset 0000 0000) and (All other resets 0000 0000) except the PIC17C42 (Power-on Reset xxxx xxxx) and (All other resets uuuu uuuu) The PRODL and PRODH registers are not implemented on the PIC17C42.
DS30412C-page 34
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 6-3: SPECIAL FUNCTION REGISTERS (Cont.'d)
Value on Power-on Reset Value on all other resets (3)
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Bank 2 10h 11h 12h 13h 14h 15h 16h 17h Bank 3 10h 11h 12h 13h 14h 15h 16h 17h PW1DCL PW2DCL PW1DCH PW2DCH CA2L CA2H TCON1 TCON2 DC1 DC1 DC9 DC9 DC0 DC0 DC8 DC8 -- TM2PW2 DC7 DC7 -- -- DC6 DC6 -- -- DC5 DC5 -- -- DC4 DC4 -- -- DC3 DC3 -- -- DC2 DC2 xx-- ---xx0- ---xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx CA1ED1 CA1ED0 T16 TMR3CS TMR2CS TMR2ON TMR1CS TMR1ON 0000 0000 0000 0000 uu-- ---uu0- ---uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000 TMR1 TMR2 TMR3L TMR3H PR1 PR2 PR3L/CA1L PR3H/CA1H Timer1 Timer2 TMR3 register; low byte TMR3 register; high byte Timer1 period register Timer2 period register Timer3 period register, low byte/capture1 register; low byte Timer3 period register, high byte/capture1 register; high byte xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu
Capture2 low byte Capture2 high byte CA2ED1 CA2ED0
CA2OVF CA1OVF PWM2ON PWM1ON CA1/PR3 TMR3ON
Unbanked 18h (5) 19h
(5)
PRODL PRODH
Low Byte of 16-bit Product (8 x 8 Hardware Multiply) High Byte of 16-bit Product (8 x 8 Hardware Multiply)
xxxx xxxx xxxx xxxx
uuuu uuuu uuuu uuuu
Legend: Note 1: 2: 3: 4:
5:
x = unknown, u = unchanged, - = unimplemented read as '0', q - value depends on condition. Shaded cells are unimplemented, read as '0'. The upper byte of the program counter is not directly accessible. PCLATH is a holding register for PC<15:8> whose contents are updated from or transferred to the upper byte of the program counter. The TO and PD status bits in CPUSTA are not affected by a MCLR reset. Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset. The following values are for both TBLPTRL and TBLPTRH: All PIC17C4X devices (Power-on Reset 0000 0000) and (All other resets 0000 0000) except the PIC17C42 (Power-on Reset xxxx xxxx) and (All other resets uuuu uuuu) The PRODL and PRODH registers are not implemented on the PIC17C42.
(c) 1996 Microchip Technology Inc.
DS30412C-page 35
PIC17C4X
6.2.2.1 ALU STATUS REGISTER (ALUSTA) The ALUSTA register contains the status bits of the Arithmetic and Logic Unit and the mode control bits for the indirect addressing register. As with all the other registers, the ALUSTA register can be the destination for any instruction. If the ALUSTA register is the destination for an instruction that affects the Z, DC or C bits, then the write to these three bits is disabled. These bits are set or cleared according to the device logic. Therefore, the result of an instruction with the ALUSTA register as destination may be different than intended. For example, CLRF ALUSTA will clear the upper four bits and set the Z bit. This leaves the ALUSTA register as 0000u1uu (where u = unchanged). It is recommended, therefore, that only BCF, BSF, SWAPF and MOVWF instructions be used to alter the ALUSTA register because these instructions do not affect any status bit. To see how other instructions affect the status bits, see the "Instruction Set Summary." Note 1: The C and DC bits operate as a borrow out bit in subtraction. See the SUBLW and SUBWF instructions for examples. Note 2: The overflow bit will be set if the 2's complement result exceeds +127 or is less than -128. Arithmetic and Logic Unit (ALU) is capable of carrying out arithmetic or logical operations on two operands or a single operand. All single operand instructions operate either on the WREG register or a file register. For two operand instructions, one of the operands is the WREG register and the other one is either a file register or an 8-bit immediate constant.
FIGURE 6-7:
ALUSTA REGISTER (ADDRESS: 04h, UNBANKED)
R/W - x OV R/W - x Z R/W - x DC R/W - x C bit0
R/W - 1 R/W - 1 R/W - 1 R/W - 1 FS3 FS2 FS1 FS0 bit7
R = Readable bit W = Writable bit -n = Value at POR reset (x = unknown)
bit 7-6: FS3:FS2: FSR1 Mode Select bits 00 = Post auto-decrement FSR1 value 01 = Post auto-increment FSR1 value 1x = FSR1 value does not change bit 5-4: FS1:FS0: FSR0 Mode Select bits 00 = Post auto-decrement FSR0 value 01 = Post auto-increment FSR0 value 1x = FSR0 value does not change bit 3: OV: Overflow bit This bit is used for signed arithmetic (2's complement). It indicates an overflow of the 7-bit magnitude, which causes the sign bit (bit7) to change state. 1 = Overflow occurred for signed arithmetic, (in this arithmetic operation) 0 = No overflow occurred Z: Zero bit 1 = The result of an arithmetic or logic operation is zero 0 = The results of an arithmetic or logic operation is not zero DC: Digit carry/borrow bit For ADDWF and ADDLW instructions. 1 = A carry-out from the 4th low order bit of the result occurred 0 = No carry-out from the 4th low order bit of the result Note: For borrow the polarity is reversed. C: carry/borrow bit For ADDWF and ADDLW instructions. 1 = A carry-out from the most significant bit of the result occurred Note that a subtraction is executed by adding the two's complement of the second operand. For rotate (RRCF, RLCF) instructions, this bit is loaded with either the high or low order bit of the source register. 0 = No carry-out from the most significant bit of the result Note: For borrow the polarity is reversed.
bit 2:
bit 1:
bit 0:
DS30412C-page 36
(c) 1996 Microchip Technology Inc.
PIC17C4X
6.2.2.2 CPU STATUS REGISTER (CPUSTA) The CPUSTA register contains the status and control bits for the CPU. This register is used to globally enable/disable interrupts. If only a specific interrupt is desired to be enabled/disabled, please refer to the INTerrupt STAtus (INTSTA) register and the Peripheral Interrupt Enable (PIE) register. This register also indicates if the stack is available and contains the Power-down (PD) and Time-out (TO) bits. The TO, PD, and STKAV bits are not writable. These bits are set and cleared according to device logic. Therefore, the result of an instruction with the CPUSTA register as destination may be different than intended.
FIGURE 6-8:
U-0 -- bit7
CPUSTA REGISTER (ADDRESS: 06h, UNBANKED)
R-1 R/W - 1 STKAV GLINTD R-1 TO R-1 PD U-0 -- U-0 -- bit0
U-0 --
R = Readable bit W = Writable bit U = Unimplemented bit, Read as `0' - n = Value at POR reset
bit 7-6: Unimplemented: Read as '0' bit 5: STKAV: Stack Available bit This bit indicates that the 4-bit stack pointer value is Fh, or has rolled over from Fh 0h (stack overflow). 1 = Stack is available 0 = Stack is full, or a stack overflow may have occurred (Once this bit has been cleared by a stack overflow, only a device reset will set this bit) GLINTD: Global Interrupt Disable bit This bit disables all interrupts. When enabling interrupts, only the sources with their enable bits set can cause an interrupt. 1 = Disable all interrupts 0 = Enables all un-masked interrupts TO: WDT Time-out Status bit 1 = After power-up or by a CLRWDT instruction 0 = A Watchdog Timer time-out occurred PD: Power-down Status bit 1 = After power-up or by the CLRWDT instruction 0 = By execution of the SLEEP instruction
bit 4:
bit 3:
bit 2:
bit 1-0: Unimplemented: Read as '0'
(c) 1996 Microchip Technology Inc.
DS30412C-page 37
PIC17C4X
6.2.2.3 TMR0 STATUS/CONTROL REGISTER (T0STA)
This register contains various control bits. Bit7 (INTEDG) is used to control the edge upon which a signal on the RA0/INT pin will set the RB0/INT interrupt flag. The other bits configure the Timer0 prescaler and clock source. (Figure 11-1).
FIGURE 6-9:
R/W - 0 INTEDG bit7
T0STA REGISTER (ADDRESS: 05h, UNBANKED)
R/W - 0 T0CS R/W - 0 PS3 R/W - 0 PS2 R/W - 0 PS1 R/W - 0 PS0 U-0 -- bit0
R/W - 0 T0SE
R = Readable bit W = Writable bit U = Unimplemented, reads as `0' -n = Value at POR reset
bit 7:
INTEDG: RA0/INT Pin Interrupt Edge Select bit This bit selects the edge upon which the interrupt is detected. 1 = Rising edge of RA0/INT pin generates interrupt 0 = Falling edge of RA0/INT pin generates interrupt T0SE: Timer0 Clock Input Edge Select bit This bit selects the edge upon which TMR0 will increment. When T0CS = 0 1 = Rising edge of RA1/T0CKI pin increments TMR0 and/or generates a T0CKIF interrupt 0 = Falling edge of RA1/T0CKI pin increments TMR0 and/or generates a T0CKIF interrupt When T0CS = 1 Don't care T0CS: Timer0 Clock Source Select bit This bit selects the clock source for Timer0. 1 = Internal instruction clock cycle (TCY) 0 = T0CKI pin
bit 6:
bit 5:
bit 4-1: PS3:PS0: Timer0 Prescale Selection bits These bits select the prescale value for Timer0. PS3:PS0 0000 0001 0010 0011 0100 0101 0110 0111 1xxx bit 0: Prescale Value 1:1 1:2 1:4 1:8 1:16 1:32 1:64 1:128 1:256
Unimplemented: Read as '0'
DS30412C-page 38
(c) 1996 Microchip Technology Inc.
PIC17C4X
6.3 Stack Operation 6.4 Indirect Addressing
The PIC17C4X devices have a 16 x 16-bit wide hardware stack (Figure 6-1). The stack is not part of either the program or data memory space, and the stack pointer is neither readable nor writable. The PC is "PUSHed" onto the stack when a CALL instruction is executed or an interrupt is acknowledged. The stack is "POPed" in the event of a RETURN, RETLW, or a RETFIE instruction execution. PCLATH is not affected by a "PUSH" or a "POP" operation. The stack operates as a circular buffer, with the stack pointer initialized to '0' after all resets. There is a stack available bit (STKAV) to allow software to ensure that the stack has not overflowed. The STKAV bit is set after a device reset. When the stack pointer equals Fh, STKAV is cleared. When the stack pointer rolls over from Fh to 0h, the STKAV bit will be held clear until a device reset. Note 1: There is not a status bit for stack underflow. The STKAV bit can be used to detect the underflow which results in the stack pointer being at the top of stack. Note 2: There are no instruction mnemonics called PUSH or POP. These are actions that occur from the execution of the CALL, RETURN, RETLW, and RETFIE instructions, or the vectoring to an interrupt vector. Note 3: After a reset, if a "POP" operation occurs before a "PUSH" operation, the STKAV bit will be cleared. This will appear as if the stack is full (underflow has occurred). If a "PUSH" operation occurs next (before another "POP"), the STKAV bit will be locked clear. Only a device reset will cause this bit to set. After the device is "PUSHed" sixteen times (without a "POP"), the seventeenth push overwrites the value from the first push. The eighteenth push overwrites the second push (and so on).
Instruction Executed Opcode Address File = INDFx Instruction Fetched Opcode File FSR
Indirect addressing is a mode of addressing data memory where the data memory address in the instruction is not fixed. That is, the register that is to be read or written can be modified by the program. This can be useful for data tables in the data memory. Figure 6-10 shows the operation of indirect addressing. This shows the moving of the value to the data memory address specified by the value of the FSR register. Example 6-1 shows the use of indirect addressing to clear RAM in a minimum number of instructions. A similar concept could be used to move a defined number of bytes (block) of data to the USART transmit register (TXREG). The starting address of the block of data to be transmitted could easily be modified by the program.
FIGURE 6-10: INDIRECT ADDRESSING
RAM
(c) 1996 Microchip Technology Inc.
DS30412C-page 39
PIC17C4X
6.4.1 INDIRECT ADDRESSING REGISTERS The PIC17C4X has four registers for indirect addressing. These registers are: * INDF0 and FSR0 * INDF1 and FSR1 Registers INDF0 and INDF1 are not physically implemented. Reading or writing to these registers activates indirect addressing, with the value in the corresponding FSR register being the address of the data. The FSR is an 8-bit register and allows addressing anywhere in the 256-byte data memory address range. For banked memory, the bank of memory accessed is specified by the value in the BSR. If file INDF0 (or INDF1) itself is read indirectly via an FSR, all '0's are read (Zero bit is set). Similarly, if INDF0 (or INDF1) is written to indirectly, the operation will be equivalent to a NOP, and the status bits are not affected. 6.4.2 INDIRECT ADDRESSING OPERATION A simple program to clear RAM from 20h - FFh is shown in Example 6-1.
EXAMPLE 6-1:
MOVLW MOVWF BCF BSF BCF MOVLW CLRF CPFSEQ GOTO : :
INDIRECT ADDRESSING
; ; ; ; ; ; ; ; ; ; ; FSR0 = 20h Increment FSR after access C=0 Addr(FSR) = 0 FSR0 = END_RAM+1? NO, clear next YES, All RAM is cleared
LP
0x20 FSR0 ALUSTA, ALUSTA, ALUSTA, END_RAM INDF0 FSR0 LP
FS1 FS0 C +1
6.5
Table Pointer (TBLPTRL and TBLPTRH)
File registers TBLPTRL and TBLPTRH form a 16-bit pointer to address the 64K program memory space. The table pointer is used by instructions TABLWT and TABLRD. The TABLRD and the TABLWT instructions allow transfer of data between program and data space. The table pointer serves as the 16-bit address of the data word within the program memory. For a more complete description of these registers and the operation of Table Reads and Table Writes, see Section 7.0.
The indirect addressing capability has been enhanced over that of the PIC16CXX family. There are two control bits associated with each FSR register. These two bits configure the FSR register to: * Auto-decrement the value (address) in the FSR after an indirect access * Auto-increment the value (address) in the FSR after an indirect access * No change to the value (address) in the FSR after an indirect access These control bits are located in the ALUSTA register. The FSR1 register is controlled by the FS3:FS2 bits and FSR0 is controlled by the FS1:FS0 bits. When using the auto-increment or auto-decrement features, the effect on the FSR is not reflected in the ALUSTA register. For example, if the indirect address causes the FSR to equal '0', the Z bit will not be set. If the FSR register contains a value of 0h, an indirect read will read 0h (Zero bit is set) while an indirect write will be equivalent to a NOP (status bits are not affected). Indirect addressing allows single cycle data transfers within the entire data space. This is possible with the use of the MOVPF and MOVFP instructions, where either 'p' or 'f' is specified as INDF0 (or INDF1). If the source or destination of the indirect address is in banked memory, the location accessed will be determined by the value in the BSR.
6.6
Table Latch (TBLATH, TBLATL)
The table latch (TBLAT) is a 16-bit register, with TBLATH and TBLATL referring to the high and low bytes of the register. It is not mapped into data or program memory. The table latch is used as a temporary holding latch during data transfer between program and data memory (see descriptions of instructions TABLRD, TABLWT, TLRD and TLWT). For a more complete description of these registers and the operation of Table Reads and Table Writes, see Section 7.0.
DS30412C-page 40
(c) 1996 Microchip Technology Inc.
PIC17C4X
6.7 Program Counter Module
Using Figure 6-11, the operations of the PC and PCLATH for different instructions are as follows: a) LCALL instructions: An 8-bit destination address is provided in the instruction (opcode). PCLATH is unchanged. PCLATH PCH Opcode<7:0> PCL Read instructions on PCL: Any instruction that reads PCL. PCL data bus ALU or destination PCH PCLATH Write instructions on PCL: Any instruction that writes to PCL. 8-bit data data bus PCL PCLATH PCH Read-Modify-Write instructions on PCL: Any instruction that does a read-write-modify operation on PCL, such as ADDWF PCL. Read: PCL data bus ALU Write: 8-bit result data bus PCL PCLATH PCH RETURN instruction: PCH PCLATH Stack PC<15:0> The Program Counter (PC) is a 16-bit register. PCL, the low byte of the PC, is mapped in the data memory. PCL is readable and writable just as is any other register. PCH is the high byte of the PC and is not directly addressable. Since PCH is not mapped in data or program memory, an 8-bit register PCLATH (PC high latch) is used as a holding latch for the high byte of the PC. PCLATH is mapped into data memory. The user can read or write PCH through PCLATH. The 16-bit wide PC is incremented after each instruction fetch during Q1 unless: * Modified by GOTO, CALL, LCALL, RETURN, RETLW, or RETFIE instruction * Modified by an interrupt response * Due to destination write to PCL by an instruction "Skips" are equivalent to a forced NOP cycle at the skipped address. Figure 6-11 and Figure 6-12 show the operation of the program counter for various situations.
b)
c)
d)
FIGURE 6-11: PROGRAM COUNTER OPERATION
Internal data bus <8> 8 PCLATH 8 PCH PCL 8
e)
Using Figure 6-12, the operation of the PC and PCLATH for GOTO and CALL instructions is a follows: CALL, GOTO instructions: A 13-bit destination address is provided in the instruction (opcode). Opcode<12:0> PC <12:0> PC<15:13> PCLATH<7:5> Opcode<12:8> PCLATH <4:0> The read-modify-write only affects the PCL with the result. PCH is loaded with the value in the PCLATH. For example, ADDWF PCL will result in a jump within the current page. If PC = 03F0h, WREG = 30h and PCLATH = 03h before instruction, PC = 0320h after the instruction. To accomplish a true 16-bit computed jump, the user needs to compute the 16-bit destination address, write the high byte to PCLATH and then write the low value to PCL. The following PC related operations do not change PCLATH:
0 PCL
FIGURE 6-12: PROGRAM COUNTER USING THE CALL AND GOTO INSTRUCTIONS
15 13 12 87 Opcode 0
Last write to PCLATH 3 7
5 8
54 0 PCLATH 8
15 PCH
87
a) b) c)
LCALL, RETLW, and RETFIE instructions. Interrupt vector is forced onto the PC. Read-modify-write instructions on PCL (e.g. BSF PCL).
(c) 1996 Microchip Technology Inc.
DS30412C-page 41
PIC17C4X
6.8 Bank Select Register (BSR)
The BSR is used to switch between banks in the data memory area (Figure 6-13). In the PIC17C42, PIC17CR42, and PIC17C42A only the lower nibble is implemented. While in the PIC17C43, PIC17CR43, and PIC17C44 devices, the entire byte is implemented. The lower nibble is used to select the peripheral register bank. The upper nibble is used to select the general purpose memory bank. All the Special Function Registers (SFRs) are mapped into the data memory space. In order to accommodate the large number of registers, a banking scheme has been used. A segment of the SFRs, from address 10h to address 17h, is banked. The lower nibble of the bank select register (BSR) selects the currently active "peripheral bank." Effort has been made to group the peripheral registers of related functionality in one bank. However, it will still be necessary to switch from bank to bank in order to address all peripherals related to a single task. To assist this, a MOVLB bank instruction is in the instruction set. For the PIC17C43, PIC17CR43, and PIC17C44 devices, the need for a large general purpose memory space dictated a general purpose RAM banking scheme. The upper nibble of the BSR selects the currently active general purpose RAM bank. To assist this, a MOVLR bank instruction has been provided in the instruction set. If the currently selected bank is not implemented (such as Bank 13), any read will read all '0's. Any write is completed to the bit bucket and the ALU status bits will be set/cleared as appropriate. Note: Registers in Bank 15 in the Special Function Register area, are reserved for Microchip use. Reading of registers in this bank may cause random values to be read.
FIGURE 6-13: BSR OPERATION (PIC17C43/R43/44)
BSR 7 43
(2) (1)
0
Address Range 10h 17h
0
1
2
3
4 ***
15 SFR Banks Bank 15
Bank 0
Bank 1
Bank 2
Bank 3
Bank 4
0 20h FFh Bank 0
1
2 *** ***
15 GPR Banks Bank 15
Bank 1
Bank 2
Note 1:
Only Banks 0 through Bank 3 are implemented. Selection of an unimplemented bank is not recommended. Bank 15 is reserved for Microchip use, reading of registers in this bank may cause random values to be read. 2: Only Banks 0 and Bank 1 are implemented. Selection of an unimplemented bank is not recommended.
DS30412C-page 42
(c) 1996 Microchip Technology Inc.
PIC17C4X
7.0 TABLE READS AND TABLE WRITES
FIGURE 7-2: TABLWT INSTRUCTION OPERATION
The PIC17C4X has four instructions that allow the processor to move data from the data memory space to the program memory space, and vice versa. Since the program memory space is 16-bits wide and the data memory space is 8-bits wide, two operations are required to move 16-bit values to/from the data memory. The TLWT t,f and TABLWT t,i,f instructions are used to write data from the data memory space to the program memory space. The TLRD t,f and TABLRD t,i,f instructions are used to write data from the program memory space to the data memory space. The program memory can be internal or external. For the program memory access to be external, the device needs to be operating in extended microcontroller or microprocessor mode. Figure 7-1 through Figure 7-4 show the operation of these four instructions.
TABLE POINTER TBLPTRH TBLPTRL
TABLE LATCH (16-bit) TABLATH TABLATL
3 TABLWT 1,i,f TABLWT
3 0,i,f
DATA MEMORY
PROGRAM MEMORY
f
1
FIGURE 7-1:
TLWT INSTRUCTION OPERATION
TBLPTRH
Prog-Mem (TBLPTR)
2
TABLE POINTER TBLPTRL
TABLE LATCH (16-bit) TABLATH TABLATL
TLWT DATA MEMORY
1,f
TLWT
0,f
PROGRAM MEMORY
Note 1: 8-bit value, from register 'f', loaded into the high or low byte in TABLAT (16-bit). 2: 16-bit TABLAT value written to address Program Memory (TBLPTR). 3: If "i" = 1, then TBLPTR = TBLPTR + 1, If "i" = 0, then TBLPTR is unchanged.
f
1
Note 1: 8-bit value, from register 'f', loaded into the high or low byte in TABLAT (16-bit).
(c) 1996 Microchip Technology Inc.
DS30412C-page 43
This document was created with FrameMaker 4 0 4
PIC17C4X
FIGURE 7-3: TLRD INSTRUCTION OPERATION
TBLPTRH TABLE LATCH (16-bit) TABLATH TLRD DATA MEMORY 1,f TABLATL TLRD 0,f 3 TABLRD PROGRAM MEMORY DATA MEMORY PROGRAM MEMORY 1,i,f TABLRD 3 0,i,f TBLPTRL
FIGURE 7-4:
TABLRD INSTRUCTION OPERATION
TBLPTRH TBLPTRL
TABLE POINTER
TABLE POINTER
TABLE LATCH (16-bit) TABLATH TABLATL
f
1
f
1
Prog-Mem (TBLPTR)
2
Note 1: 8-bit value, from TABLAT (16-bit) high or low byte, loaded into register 'f'.
Note 1: 8-bit value, from TABLAT (16-bit) high or low byte, loaded into register 'f'. 2: 16-bit value at Program Memory (TBLPTR) loaded into TABLAT register. 3: If "i" = 1, then TBLPTR = TBLPTR + 1, If "i" = 0, then TBLPTR is unchanged.
DS30412C-page 44
(c) 1996 Microchip Technology Inc.
PIC17C4X
7.1 Table Writes to Internal Memory
7.1.1 TERMINATING LONG WRITES A table write operation to internal memory causes a long write operation. The long write is necessary for programming the internal EPROM. Instruction execution is halted while in a long write cycle. The long write will be terminated by any enabled interrupt. To ensure that the EPROM location has been well programmed, a minimum programming time is required (see specification #D114 ). Having only one interrupt enabled to terminate the long write ensures that no unintentional interrupts will prematurely terminate the long write. The sequence of events for programming an internal program memory location should be: 1. 2. 3. 4. 5. Disable all interrupt sources, except the source to terminate EPROM program write. Raise MCLR/VPP pin to the programming voltage. Clear the WDT. Do the table write. The interrupt will terminate the long write. Verify the memory location (table read). Note: Programming requirements must be met. See timing specification in electrical specifications for the desired device. Violating these specifications (including temperature) may result in EPROM locations that are not fully programmed and may lose their state over time. An interrupt source or reset are the only events that terminate a long write operation. Terminating the long write from an interrupt source requires that the interrupt enable and flag bits are set. The GLINTD bit only enables the vectoring to the interrupt address. If the T0CKI, RA0/INT, or TMR0 interrupt source is used to terminate the long write; the interrupt flag, of the highest priority enabled interrupt, will terminate the long write and automatically be cleared. Note 1: If an interrupt is pending, the TABLWT is aborted (an NOP is executed). The highest priority pending interrupt, from the T0CKI, RA0/INT, or TMR0 sources that is enabled, has its flag cleared. Note 2: If the interrupt is not being used for the program write timing, the interrupt should be disabled. This will ensure that the interrupt is not lost, nor will it terminate the long write prematurely. If a peripheral interrupt source is used to terminate the long write, the interrupt enable and flag bits must be set. The interrupt flag will not be automatically cleared upon the vectoring to the interrupt vector address. If the GLINTD bit is cleared prior to the long write, when the long write is terminated, the program will branch to the interrupt vector. If the GLINTD bit is set prior to the long write, when the long write is terminated, the program will not vector to the interrupt address.
TABLE 7-1:
Interrupt Source RA0/INT, TMR0, T0CKI
INTERRUPT - TABLE WRITE INTERACTION
Enable Bit 1 Flag Bit 1
GLINTD 0
Action Terminate long table write (to internal program memory), branch to interrupt vector (branch clears flag bit). None None Terminate table write, do not branch to interrupt vector (flag is automatically cleared). Terminate table write, branch to interrupt vector. None None Terminate table write, do not branch to interrupt vector (flag is set).
0 1 1 Peripheral
1 0 1
0 x 1
0 0 1 1
1 1 0 1
1 0 x 1
(c) 1996 Microchip Technology Inc.
DS30412C-page 45
PIC17C4X
7.2 Table Writes to External Memory
7.2.2 TABLE WRITE CODE Table writes to external memory are always two-cycle instructions. The second cycle writes the data to the external memory location. The sequence of events for an external memory write are the same for an internal write. Note: If an interrupt is pending or occurs during the TABLWT, the two cycle table write completes. The RA0/INT, TMR0, or T0CKI interrupt flag is automatically cleared or the pending peripheral interrupt is acknowledged. The "i" operand of the TABLWT instruction can specify that the value in the 16-bit TBLPTR register is automatically incremented for the next write. In Example 7-1, the TBLPTR register is not automatically incremented.
EXAMPLE 7-1:
CLRWDT MOVLW MOVWF MOVLW MOVWF MOVLW TLWT MOVLW TABLWT
TABLE WRITE
; ; ; ; ; ; ; ; ; ; ; ; Clear WDT Load the Table address
HIGH (TBL_ADDR) TBLPTRH LOW (TBL_ADDR) TBLPTRL HIGH (DATA) 1, WREG LOW (DATA) 0,0,WREG
Load HI byte in TABLATCH Load LO byte in TABLATCH and write to program memory (Ext. SRAM)
FIGURE 7-5:
TABLWT WRITE TIMING (EXTERNAL MEMORY)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
AD15:AD0
PC
PC+1
TBL
Data out
PC+2
Instruction fetched Instruction executed
TABLWT INST (PC-1)
INST (PC+1) TABLWT cycle1 TABLWT cycle2 Data write cycle
INST (PC+2) INST (PC+1)
ALE OE '1' WR
Note:
If external write GLINTD = '1', Enable bit = '1', '1' Flag bit, Do table write. The highest pending interrupt is cleared.
DS30412C-page 46
(c) 1996 Microchip Technology Inc.
PIC17C4X
FIGURE 7-6: CONSECUTIVE TABLWT WRITE TIMING (EXTERNAL MEMORY)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
AD15:AD0 Instruction fetched Instruction executed
PC
PC+1
TBL1
Data out 1
PC+2
TBL2
Data out 2
PC+3
TABLWT1 INST (PC-1)
TABLWT2
INST (PC+2)
INST (PC+3) INST (PC+2)
TABLWT1 cycle1 TABLWT1 cycle2 TABLWT2 cycle1 TABLWT2 cycle2 Data write cycle Data write cycle
ALE OE WR
(c) 1996 Microchip Technology Inc.
DS30412C-page 47
PIC17C4X
7.3 Table Reads EXAMPLE 7-2:
MOVLW MOVWF MOVLW MOVWF TABLRD TLRD TABLRD
TABLE READ
; ; ; ; ; ; ; ; ; ; ; Load the Table address
The table read allows the program memory to be read. This allows constant data to be stored in the program memory space, and retrieved into data memory when needed. Example 7-2 reads the 16-bit value at program memory address TBLPTR. After the dummy byte has been read from the TABLATH, the TABLATH is loaded with the 16-bit data from program memory address TBLPTR + 1. The first read loads the data into the latch, and can be considered a dummy read (unknown data loaded into 'f'). INDF0 should be configured for either auto-increment or auto-decrement.
HIGH (TBL_ADDR) TBLPTRH LOW (TBL_ADDR) TBLPTRL 0,0,DUMMY 1, INDF0 0,1,INDF0
Dummy read, Updates TABLATCH Read HI byte of TABLATCH Read LO byte of TABLATCH and Update TABLATCH
FIGURE 7-7:
TABLRD TIMING
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
AD15:AD0
PC
PC+1
TBL
Data in
PC+2
Instruction fetched Instruction executed
TABLRD INST (PC-1)
INST (PC+1) TABLRD cycle2 Data read cycle
INST (PC+2) INST (PC+1)
TABLRD cycle1
ALE OE '1'
WR
FIGURE 7-8:
TABLRD TIMING (CONSECUTIVE TABLRD INSTRUCTIONS)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
AD15:AD0 Instruction fetched Instruction executed
PC
PC+1
TBL1 Data in 1
PC+2
TBL2
Data in 2
PC+3
TABLRD1 INST (PC-1)
TABLRD2
INST (PC+2)
INST (PC+3) INST (PC+2)
TABLRD1 cycle1 TABLRD1 cycle2 TABLRD2 cycle1 TABLRD2 cycle2 Data read cycle Data read cycle
ALE OE '1' WR
DS30412C-page 48
(c) 1996 Microchip Technology Inc.
PIC17C4X
8.0 HARDWARE MULTIPLIER
All PIC17C4X devices except the PIC17C42, have an 8 x 8 hardware multiplier included in the ALU of the device. By making the multiply a hardware operation, it completes in a single instruction cycle. This is an unsigned multiply that gives a 16-bit result. The result is stored into the 16-bit PRODuct register (PRODH:PRODL). The multiplier does not affect any flags in the ALUSTA register. Making the 8 x 8 multiplier execute in a single cycle gives the following advantages: * Higher computational throughput * Reduces code size requirements for multiply algorithms The performance increase allows the device to be used in applications previously reserved for Digital Signal Processors. Table 8-1 shows a performance comparison between the PIC17C42 and all other PIC17CXX devices, which have the single cycle hardware multiply. Example 8-1 shows the sequence to do an 8 x 8 unsigned multiply. Only one instruction is required when one argument of the multiply is already loaded in the WREG register. Example 8-2 shows the sequence to do an 8 x 8 signed multiply. To account for the sign bits of the arguments, each argument's most significant bit (MSb) is tested and the appropriate subtractions are done.
EXAMPLE 8-1:
MOVFP MULWF
8 x 8 MULTIPLY ROUTINE
; ARG1 * ARG2 -> ; PRODH:PRODL
ARG1, WREG ARG2
EXAMPLE 8-2:
MOVFP MULWF BTFSC SUBWF MOVFP BTFSC SUBWF
8 x 8 SIGNED MULTIPLY ROUTINE
; ARG1 * ARG2 -> ; PRODH:PRODL ; Test Sign Bit ; PRODH = PRODH ; - ARG1 ; Test Sign Bit ; PRODH = PRODH ; - ARG2
ARG1, WREG ARG2 ARG2, SB PRODH, F ARG2, WREG ARG1, SB PRODH, F
TABLE 8-1:
Routine 8 x 8 unsigned 8 x 8 signed 16 x 16 unsigned 16 x 16 signed
PERFORMANCE COMPARISON
Device PIC17C42 All other PIC17CXX devices PIC17C42 All other PIC17CXX devices PIC17C42 All other PIC17CXX devices PIC17C42 All other PIC17CXX devices Program Memory (Words) 13 1 -- 6 21 24 52 36 Time Cycles (Max) @ 25 MHz 69 1 -- 6 242 24 254 36 11.04 s 160 ns -- 960 ns 38.72 s 3.84 s 40.64 s 5.76 s @ 33 MHz N/A 121 ns N/A 727 ns N/A 2.91 s N/A 4.36 s
(c) 1996 Microchip Technology Inc.
DS30412C-page 49
This document was created with FrameMaker 4 0 4
PIC17C4X
Example 8-3 shows the sequence to do a 16 x 16 unsigned multiply. Equation 8-1 shows the algorithm that is used. The 32-bit result is stored in 4 registers RES3:RES0.
EXAMPLE 8-3:
MOVFP MULWF MOVPF MOVPF ; MOVFP MULWF MOVPF MOVPF ; MOVFP MULWF MOVFP ADDWF MOVFP ADDWFC CLRF ADDWFC ; MOVFP MULWF
16 x 16 MULTIPLY ROUTINE
EQUATION 8-1:
16 x 16 UNSIGNED MULTIPLICATION ALGORITHM
ARG1H:ARG1L * ARG2H:ARG2L (ARG1H * ARG2H * 216) + (ARG1H * ARG2L * 28) (ARG1L * ARG2H * (ARG1L * ARG2L) 28) + +
ARG1L, WREG ARG2L ; ARG1L * ARG2L -> ; PRODH:PRODL PRODH, RES1 ; PRODL, RES0 ; ARG1H, WREG ARG2H ; ARG1H * ARG2H -> ; PRODH:PRODL PRODH, RES3 ; PRODL, RES2 ; ARG1L, WREG ARG2H ; ARG1L * ARG2H -> ; PRODH:PRODL PRODL, WREG ; RES1, F ; Add cross PRODH, WREG ; products RES2, F ; WREG, F ; RES3, F ; ARG1H, WREG ; ARG2L ; ARG1H * ARG2L -> ; PRODH:PRODL PRODL, WREG RES1, F PRODH, WREG RES2, F WREG, F RES3, F ; ; Add cross ; products ; ; ;
RES3:RES0
= =
MOVFP ADDWF MOVFP ADDWFC CLRF ADDWFC
DS30412C-page 50
(c) 1996 Microchip Technology Inc.
PIC17C4X
Example 8-4 shows the sequence to do an 16 x 16 signed multiply. Equation 8-2 shows the algorithm that used. The 32-bit result is stored in four registers RES3:RES0. To account for the sign bits of the arguments, each argument pairs most significant bit (MSb) is tested and the appropriate subtractions are done.
EXAMPLE 8-4:
MOVFP MULWF MOVPF MOVPF ; MOVFP MULWF MOVPF MOVPF ;
16 x 16 SIGNED MULTIPLY ROUTINE
ARG1L, WREG ARG2L ; ARG1L * ARG2L -> ; PRODH:PRODL PRODH, RES1 ; PRODL, RES0 ; ARG1H, WREG ARG2H ; ARG1H * ARG2H -> ; PRODH:PRODL PRODH, RES3 ; PRODL, RES2 ; ARG1L, WREG ARG2H ; ARG1L * ARG2H -> ; PRODH:PRODL PRODL, WREG ; RES1, F ; Add cross PRODH, WREG ; products RES2, F ; WREG, F ; RES3, F ; ARG1H, WREG ; ARG2L ; ARG1H * ARG2L -> ; PRODH:PRODL PRODL, WREG RES1, F PRODH, WREG RES2, F WREG, F RES3, F ARG2H, 7 SIGN_ARG1 ARG1L, WREG RES2 ARG1H, WREG RES3 ; ; Add cross ; products ; ; ; ; ARG2H:ARG2L neg? ; no, check ARG1 ; ; ;
EQUATION 8-2:
16 x 16 SIGNED MULTIPLICATION ALGORITHM
RES3:RES0 = ARG1H:ARG1L * ARG2H:ARG2L = (ARG1H * ARG2H * 2 ) (ARG1H * ARG2L * 28) (ARG1L * ARG2H * (ARG1L * ARG2L) (-1 * ARG1H<7> * ARG2H:ARG2L * 216)
;
16
+ + + +
MOVFP MULWF MOVFP ADDWF MOVFP ADDWFC CLRF ADDWFC MOVFP MULWF
28)
(-1 * ARG2H<7> * ARG1H:ARG1L * 216) +
MOVFP ADDWF MOVFP ADDWFC CLRF ADDWFC ; BTFSS GOTO MOVFP SUBWF MOVFP SUBWFB ; SIGN_ARG1 BTFSS GOTO MOVFP SUBWF MOVFP SUBWFB ; CONT_CODE :
ARG1H, 7 CONT_CODE ARG2L, WREG RES2 ARG2H, WREG RES3
; ARG1H:ARG1L neg? ; no, done ; ; ;
(c) 1996 Microchip Technology Inc.
DS30412C-page 51
PIC17C4X
NOTES:
DS30412C-page 52
(c) 1996 Microchip Technology Inc.
PIC17C4X
9.0 I/O PORTS
9.1 PORTA Register
The PIC17C4X devices have five I/O ports, PORTA through PORTE. PORTB through PORTE have a corresponding Data Direction Register (DDR), which is used to configure the port pins as inputs or outputs. These five ports are made up of 33 I/O pins. Some of these ports pins are multiplexed with alternate functions. PORTC, PORTD, and PORTE are multiplexed with the system bus. These pins are configured as the system bus when the device's configuration bits are selected to Microprocessor or Extended Microcontroller modes. In the two other microcontroller modes, these pins are general purpose I/O. PORTA and PORTB are multiplexed with the peripheral features of the device. These peripheral features are: * * * * * Timer modules Capture module PWM module USART/SCI module External Interrupt pin PORTA is a 6-bit wide latch. PORTA does not have a corresponding Data Direction Register (DDR). Reading PORTA reads the status of the pins. The RA1 pin is multiplexed with TMR0 clock input, and RA4 and RA5 are multiplexed with the USART functions. The control of RA4 and RA5 as outputs is automatically configured by the USART module. 9.1.1 USING RA2, RA3 AS OUTPUTS
The RA2 and RA3 pins are open drain outputs. To use the RA2 or the RA3 pin(s) as output(s), simply write to the PORTA register the desired value. A '0' will cause the pin to drive low, while a '1' will cause the pin to float (hi-impedance). An external pull-up resistor should be used to pull the pin high. Writes to PORTA will not affect the other pins. Note: When using the RA2 or RA3 pin(s) as output(s), read-modify-write instructions (such as BCF, BSF, BTG) on PORTA are not recommended. Such operations read the port pins, do the desired operation, and then write this value to the data latch. This may inadvertently cause the RA2 or RA3 pins to switch from input to output (or vice-versa). It is recommended to use a shadow register for PORTA. Do the bit operations on this shadow register and then move it to PORTA.
When some of these peripheral modules are turned on, the port pin will automatically configure to the alternate function. The modules that do this are: * PWM module * USART/SCI module When a pin is automatically configured as an output by a peripheral module, the pins data direction (DDR) bit is unknown. After disabling the peripheral module, the user should re-initialize the DDR bit to the desired configuration. The other peripheral modules (which require an input) must have their data direction bit configured appropriately. Note: A pin that is a peripheral input, can be configured as an output (DDRx is cleared). The peripheral events will be determined by the action output on the port pin.
FIGURE 9-1:
RA0 AND RA1 BLOCK DIAGRAM
DATA BUS
RD_PORTA (Q2) Note: I/O pins have protection diodes to VDD and VSS.
(c) 1996 Microchip Technology Inc.
DS30412C-page 53
This document was created with FrameMaker 4 0 4
PIC17C4X
FIGURE 9-2: RA2 AND RA3 BLOCK DIAGRAM
Data Bus Serial port input signal
FIGURE 9-3:
RA4 AND RA5 BLOCK DIAGRAM
Data Bus
Q
D
RD_PORTA (Q2) WR_PORTA (Q4)
RD_PORTA (Q2) Serial port output signals OE = SPEN,SYNC,TXEN, CREN, SREN for RA4 OE = SPEN (SYNC+SYNC,CSRC) for RA5
Q
CK
Note: I/O pins have protection diodes to VSS.
Note: I/O pins have protection diodes to VDD and VSS.
TABLE 9-1:
Name
PORTA FUNCTIONS
Bit0 Buffer Type Function Input or external interrupt input. Input or clock input to the TMR0 timer/counter, and/or an external interrupt input. Input/Output. Output is open drain type. Input/Output. Output is open drain type. Input or USART Asynchronous Receive or USART Synchronous Data. Input or USART Asynchronous Transmit or USART Synchronous Clock. Control bit for PORTB weak pull-ups.
RA0/INT bit0 ST RA1/T0CKI bit1 ST RA2 bit2 ST RA3 bit3 ST RA4/RX/DT bit4 ST RA5/TX/CK bit5 ST RBPU bit7 -- Legend: ST = Schmitt Trigger input.
TABLE 9-2:
Address
REGISTERS/BITS ASSOCIATED WITH PORTA
Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0-xx xxxx 0000 0000000 -00x 0000 --1x Value on all other resets (Note1) 0-uu uuuu 0000 0000000 -00u 0000 --1u
10h, Bank 0 05h, Unbanked 13h, Bank 0 15h, Bank 0
PORTA T0STA RCSTA TXSTA
RBPU INTEDG SPEN CSRC
-- T0SE RC9 TX9
RA5 T0CS SREN TXEN
RA4 PS3 CREN SYNC
RA3 PS2 -- --
RA2 PS1 FERR --
RA1/T0CKI PS0 OERR TRMT
RA0/INT -- RC9D TX9D
Legend: x = unknown, u = unchanged, - = unimplemented reads as '0'. Shaded cells are not used by PORTA. Note 1: Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset.
DS30412C-page 54
(c) 1996 Microchip Technology Inc.
PIC17C4X
9.2 PORTB and DDRB Registers
PORTB is an 8-bit wide bi-directional port. The corresponding data direction register is DDRB. A '1' in DDRB configures the corresponding port pin as an input. A '0' in the DDRB register configures the corresponding port pin as an output. Reading PORTB reads the status of the pins, whereas writing to it will write to the port latch. Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is done by clearing the RBPU (PORTA<7>) bit. The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are enabled on any reset. PORTB also has an interrupt on change feature. Only pins configured as inputs can cause this interrupt to occur (i.e. any RB7:RB0 pin configured as an output is excluded from the interrupt on change comparison). The input pins (of RB7:RB0) are compared with the value in the PORTB data latch. The "mismatch" outputs of RB7:RB0 are OR'ed together to generate the PORTB Interrupt Flag RBIF (PIR<7>). This interrupt can wake the device from SLEEP. The user, in the interrupt service routine, can clear the interrupt by: a) b) Read-Write PORTB (such as; MOVPF PORTB, PORTB). This will end mismatch condition. Then, clear the RBIF bit.
A mismatch condition will continue to set the RBIF bit. Reading then writing PORTB will end the mismatch condition, and allow the RBIF bit to be cleared. This interrupt on mismatch feature, together with software configurable pull-ups on this port, allows easy interface to a key pad and make it possible for wake-up on key-depression. For an example, refer to AN552 in the Embedded Control Handbook. The interrupt on change feature is recommended for wake-up on operations where PORTB is only used for the interrupt on change feature and key depression operation.
FIGURE 9-4:
BLOCK DIAGRAM OF RB<7:4> AND RB<1:0> PORT PINS
Peripheral Data in RBPU (PORTA<7>)
Weak Pull-Up
Match Signal from other port pins Port Input Latch
RBIF
Data Bus
RD_DDRB (Q2)
RD_PORTB (Q2) D OE Q CK D Port Data Note: I/O pins have protection diodes to VDD and VSS. Q CK WR_PORTB (Q4) WR_DDRB (Q4)
(c) 1996 Microchip Technology Inc.
DS30412C-page 55
PIC17C4X
FIGURE 9-5: BLOCK DIAGRAM OF RB3 AND RB2 PORT PINS
Peripheral Data in RBPU (PORTA<7>) Weak Pull-Up Match Signal from other port pins RBIF Port Input Latch Data Bus
RD_DDRB (Q2)
RD_PORTB (Q2) D OE Q CK D Port Data Q CK R WR_PORTB (Q4) WR_DDRB (Q4)
PWM_output PWM_select
Note: I/O pins have protection diodes to VDD and Vss.
DS30412C-page 56
(c) 1996 Microchip Technology Inc.
PIC17C4X
Example 9-1 shows the instruction sequence to initialize PORTB. The Bank Select Register (BSR) must be selected to Bank 0 for the port to be initialized.
EXAMPLE 9-1:
MOVLB 0 CLRF PORTB
INITIALIZING PORTB
; Select Bank 0 ; Initialize PORTB by clearing ; output data latches data direction Set RB<3:0> as inputs RB<5:4> as outputs RB<7:6> as inputs ; Value used to initialize ; ; ; ;
MOVLW 0xCF MOVWF DDRB
TABLE 9-3:
Name RB0/CAP1 RB1/CAP2 RB2/PWM1 RB3/PWM2 RB4/TCLK12 RB5/TCLK3 RB6 RB7
PORTB FUNCTIONS
Bit bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 Buffer Type ST ST ST ST ST ST ST ST Function Input/Output or the RB0/CAP1 input pin. Software programmable weak pullup and interrupt on change features. Input/Output or the RB1/CAP2 input pin. Software programmable weak pullup and interrupt on change features. Input/Output or the RB2/PWM1 output pin. Software programmable weak pull-up and interrupt on change features. Input/Output or the RB3/PWM2 output pin. Software programmable weak pull-up and interrupt on change features. Input/Output or the external clock input to Timer1 and Timer2. Software programmable weak pull-up and interrupt on change features. Input/Output or the external clock input to Timer3. Software programmable weak pull-up and interrupt on change features. Input/Output pin. Software programmable weak pull-up and interrupt on change features. Input/Output pin. Software programmable weak pull-up and interrupt on change features.
Legend: ST = Schmitt Trigger input.
TABLE 9-4:
Address
REGISTERS/BITS ASSOCIATED WITH PORTB
Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset Value on all other resets (Note1)
12h, Bank 0 11h, Bank 0 10h, Bank 0 06h, Unbanked 07h, Unbanked 16h, Bank 1 17h, Bank 1 16h, Bank 3 17h, Bank 3
PORTB DDRB PORTA CPUSTA INTSTA PIR PIE TCON1 TCON2
PORTB data latch Data direction register for PORTB RBPU -- PEIF RBIF RBIE -- -- T0CKIF TMR3IF TMR3IE RA5 STKAV T0IF TMR2IF TMR2IE CA1ED1 RA4 GLINTD INTF TMR1IF TMR1IE CA1ED0 RA3 TO PEIE CA2IF CA2IE T16 RA2 PD T0CKIE CA1IF CA1IE TMR3CS RA1/T0CKI -- T0IE TXIF TXIE TMR2CS TMR2ON RA0/INT -- INTE RCIF RCIE
xxxx xxxx uuuu uuuu 1111 1111 1111 1111 0-xx xxxx 0-uu uuuu --11 11-- --11 qq-0000 0000 0000 0000 0000 0010 0000 0010 0000 0000 0000 0000
CA2ED1 CA2ED0
TMR1CS 0000 0000 0000 0000 TMR1ON 0000 0000 0000 0000
CA2OVF CA1OVF PWM2ON PWM1ON CA1/PR3 TMR3ON
Legend: x = unknown, u = unchanged, - = unimplemented read as '0', q = Value depends on condition. Shaded cells are not used by PORTB. Note 1: Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset.
(c) 1996 Microchip Technology Inc.
DS30412C-page 57
PIC17C4X
9.3 PORTC and DDRC Registers
PORTC is an 8-bit bi-directional port. The corresponding data direction register is DDRC. A '1' in DDRC configures the corresponding port pin as an input. A '0' in the DDRC register configures the corresponding port pin as an output. Reading PORTC reads the status of the pins, whereas writing to it will write to the port latch. PORTC is multiplexed with the system bus. When operating as the system bus, PORTC is the low order byte of the address/data bus (AD7:AD0). The timing for the system bus is shown in the Electrical Characteristics section. Note: This port is configured as the system bus when the device's configuration bits are selected to Microprocessor or Extended Microcontroller modes. In the two other microcontroller modes, this port is a general purpose I/O. Example 9-2 shows the instruction sequence to initialize PORTC. The Bank Select Register (BSR) must be selected to Bank 1 for the port to be initialized.
EXAMPLE 9-2:
MOVLB 1 CLRF PORTC
INITIALIZING PORTC
; ; ; ; ; ; ; ; ; Select Bank 1 Initialize PORTC data latches before setting the data direction register Value used to initialize data direction Set RC<3:0> as inputs RC<5:4> as outputs RC<7:6> as inputs
MOVLW 0xCF MOVWF DDRC
;
FIGURE 9-6:
BLOCK DIAGRAM OF RC<7:0> PORT PINS
to D_Bus IR INSTRUCTION READ
Data Bus TTL Input Buffer
RD_PORTC
0 1
Port Data
Q CK
D WR_PORTC
Q CK S
D
RD_DDRC WR_DDRC
R
EX_EN DATA/ADDR_OUT DRV_SYS Note: I/O pins have protection diodes to VDD and Vss. SYS BUS Control
DS30412C-page 58
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 9-5:
Name RC0/AD0 RC1/AD1 RC2/AD2 RC3/AD3 RC4/AD4 RC5/AD5 RC6/AD6 RC7/AD7
PORTC FUNCTIONS
Bit bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 Buffer Type TTL TTL TTL TTL TTL TTL TTL TTL Function Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin.
Legend: TTL = TTL input.
TABLE 9-6:
Address Name
REGISTERS/BITS ASSOCIATED WITH PORTC
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset xxxx xxxx 1111 1111 Value on all other resets (Note1) uuuu uuuu 1111 1111
11h, Bank 1 10h, Bank 1
PORTC DDRC
RC7/ AD7
RC6/ AD6
RC5/ AD5
RC4/ AD4
RC3/ AD3
RC2/ AD2
RC1/ AD1
RC0/ AD0
Data direction register for PORTC
Legend: x = unknown, u = unchanged. Note 1: Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset.
(c) 1996 Microchip Technology Inc.
DS30412C-page 59
PIC17C4X
9.4 PORTD and DDRD Registers
PORTD is an 8-bit bi-directional port. The corresponding data direction register is DDRD. A '1' in DDRD configures the corresponding port pin as an input. A '0' in the DDRC register configures the corresponding port pin as an output. Reading PORTD reads the status of the pins, whereas writing to it will write to the port latch. PORTD is multiplexed with the system bus. When operating as the system bus, PORTD is the high order byte of the address/data bus (AD15:AD8). The timing for the system bus is shown in the Electrical Characteristics section. Note: This port is configured as the system bus when the device's configuration bits are selected to Microprocessor or Extended Microcontroller modes. In the two other microcontroller modes, this port is a general purpose I/O. Example 9-3 shows the instruction sequence to initialize PORTD. The Bank Select Register (BSR) must be selected to Bank 1 for the port to be initialized.
EXAMPLE 9-3:
MOVLB 1 CLRF PORTD
INITIALIZING PORTD
; ; ; ; ; ; ; ; ; Select Bank 1 Initialize PORTD data latches before setting the data direction register Value used to initialize data direction Set RD<3:0> as inputs RD<5:4> as outputs RD<7:6> as inputs
MOVLW 0xCF MOVWF DDRD
;
FIGURE 9-7:
PORTD BLOCK DIAGRAM (IN I/O PORT MODE)
to D_Bus IR INSTRUCTION READ
Data Bus TTL Input Buffer
RD_PORTD
0 1
Port Data
Q CK
D WR_PORTD
Q CK S
D
RD_DDRD WR_DDRD
R
EX_EN DATA/ADDR_OUT DRV_SYS Note: I/O pins have protection diodes to VDD and Vss. SYS BUS Control
DS30412C-page 60
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 9-7:
Name
PORTD FUNCTIONS
Bit Buffer Type TTL TTL TTL TTL TTL TTL TTL TTL Function Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin. Input/Output or system bus address/data pin.
RD0/AD8 bit0 RD1/AD9 bit1 RD2/AD10 bit2 RD3/AD11 bit3 RD4/AD12 bit4 RD5/AD13 bit5 RD6/AD14 bit6 RD7/AD15 bit7 Legend: TTL = TTL input.
TABLE 9-8:
Address Name
REGISTERS/BITS ASSOCIATED WITH PORTD
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset xxxx xxxx 1111 1111 Value on all other resets (Note1) uuuu uuuu 1111 1111
13h, Bank 1 12h, Bank 1
PORTD DDRD
RD7/ AD15
RD6/ AD14
RD5/ AD13
RD4/ AD12
RD3/ AD11
RD2/ AD10
RD1/ AD9
RD0/ AD8
Data direction register for PORTD
Legend: x = unknown, u = unchanged. Note 1: Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset.
(c) 1996 Microchip Technology Inc.
DS30412C-page 61
PIC17C4X
9.4.1 PORTE AND DDRE REGISTER PORTE is a 3-bit bi-directional port. The corresponding data direction register is DDRE. A '1' in DDRE configures the corresponding port pin as an input. A '0' in the DDRE register configures the corresponding port pin as an output. Reading PORTE reads the status of the pins, whereas writing to it will write to the port latch. PORTE is multiplexed with the system bus. When operating as the system bus, PORTE contains the control signals for the address/data bus (AD15:AD0). These control signals are Address Latch Enable (ALE), Output Enable (OE), and Write (WR). The control signals OE and WR are active low signals. The timing for the system bus is shown in the Electrical Characteristics section. Note: This port is configured as the system bus when the device's configuration bits are selected to Microprocessor or Extended Microcontroller modes. In the two other microcontroller modes, this port is a general purpose I/O. Example 9-4 shows the instruction sequence to initialize PORTE. The Bank Select Register (BSR) must be selected to Bank 1 for the port to be initialized.
EXAMPLE 9-4:
MOVLB 1 CLRF PORTE
INITIALIZING PORTE
; ; ; ; ; ; ; ; ; Select Bank 1 Initialize PORTE data latches before setting the data direction register Value used to initialize data direction Set RE<1:0> as inputs RE<2> as outputs RE<7:3> are always read as '0'
MOVLW 0x03 MOVWF DDRE
; ;
FIGURE 9-8:
PORTE BLOCK DIAGRAM (IN I/O PORT MODE)
Data Bus TTL Input Buffer RD_PORTE
Port 0 Data 1
Q CK
D WR_PORTE
Q CK S
D
RD_DDRE WR_DDRE
R
EX_EN CNTL DRV_SYS Note: I/O pins have protection diodes to VDD and Vss. SYS BUS Control
DS30412C-page 62
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 9-9:
Name
PORTE FUNCTIONS
Bit Buffer Type TTL TTL TTL Function Input/Output or system bus Address Latch Enable (ALE) control pin. Input/Output or system bus Output Enable (OE) control pin. Input/Output or system bus Write (WR) control pin.
RE0/ALE bit0 RE1/OE bit1 RE2/WR bit2 Legend: TTL = TTL input.
TABLE 9-10:
Address Name
REGISTERS/BITS ASSOCIATED WITH PORTE
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset ---- -xxx ---- -111 Value on all other resets (Note1) ---- -uuu ---- -111
15h, Bank 1 14h, Bank 1
PORTE DDRE
--
--
--
--
--
RE2/WR
RE1/OE
RE0/ALE
Data direction register for PORTE
Legend: x = unknown, u = unchanged, - = unimplemented read as '0'. Shaded cells are not used by PORTE. Note 1: Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset.
(c) 1996 Microchip Technology Inc.
DS30412C-page 63
PIC17C4X
9.5
9.5.1
I/O Programming Considerations
BI-DIRECTIONAL I/O PORTS
EXAMPLE 9-5:
READ MODIFY WRITE INSTRUCTIONS ON AN I/O PORT
Any instruction which writes, operates internally as a read followed by a write operation. For example, the BCF and BSF instructions read the register into the CPU, execute the bit operation, and write the result back to the register. Caution must be used when these instructions are applied to a port with both inputs and outputs defined. For example, a BSF operation on bit5 of PORTB will cause all eight bits of PORTB to be read into the CPU. Then the BSF operation takes place on bit5 and PORTB is written to the output latches. If another bit of PORTB is used as a bi-directional I/O pin (e.g. bit0) and it is defined as an input at this time, the input signal present on the pin itself would be read into the CPU and re-written to the data latch of this particular pin, overwriting the previous content. As long as the pin stays in the input mode, no problem occurs. However, if bit0 is switched into output mode later on, the content of the data latch may now be unknown. Reading a port reads the values of the port pins. Writing to the port register writes the value to the port latch. When using read-modify-write instructions (BCF, BSF, BTG, etc.) on a port, the value of the port pins is read, the desired operation is performed with this value, and the value is then written to the port latch. Example 9-5 shows the effect of two sequential read-modify-write instructions on an I/O port.
; Initial PORT settings: PORTB<7:4> Inputs ; PORTB<3:0> Outputs ; PORTB<7:6> have pull-ups and are ; not connected to other circuitry ; ; PORT latch PORT pins ; ---------- --------; BCF PORTB, 7 01pp pppp 11pp pppp BCF PORTB, 6 10pp pppp 11pp pppp ; BCF DDRB, 7 10pp pppp 11pp pppp BCF DDRB, 6 10pp pppp 10pp pppp ; ; Note that the user may have expected the ; pin values to be 00pp pppp. The 2nd BCF ; caused RB7 to be latched as the pin value ; (High).
Note:
A pin actively outputting a Low or High should not be driven from external devices in order to change the level on this pin (i.e. "wired-or", "wired-and"). The resulting high output currents may damage the device. SUCCESSIVE OPERATIONS ON I/O PORTS
9.5.2
The actual write to an I/O port happens at the end of an instruction cycle, whereas for reading, the data must be valid at the beginning of the instruction cycle (Figure 99). Therefore, care must be exercised if a write followed by a read operation is carried out on the same I/O port. The sequence of instructions should be such to allow the pin voltage to stabilize (load dependent) before executing the instruction that reads the values on that I/O port. Otherwise, the previous state of that pin may be read into the CPU rather than the "new" state. When in doubt, it is better to separate these instructions with a NOP or another instruction not accessing this I/O port.
FIGURE 9-9:
SUCCESSIVE I/O OPERATION
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 PC PC + 1 PC + 2 NOP PC + 3 NOP
Note: This example shows a write to PORTB followed by a read from PORTB. Note that: data setup time = (0.25 TCY - TPD) where TCY = instruction cycle. TPD = propagation delay Therefore, at higher clock frequencies, a write followed by a read may be problematic.
Instruction fetched
MOVWF PORTB MOVF PORTB,W write to PORTB
RB7:RB0 Port pin sampled here Instruction executed MOVWF PORTB write to PORTB MOVF PORTB,W NOP
DS30412C-page 64
(c) 1996 Microchip Technology Inc.
PIC17C4X
10.0 OVERVIEW OF TIMER RESOURCES
10.3 Timer2 Overview
The TMR2 module is an 8-bit timer/counter with an 8bit period register (PR2). When the TMR2 value rolls over from the period match value to 0h, the TMR2IF flag is set, and an interrupt will be generated when enabled. In counter mode, the clock comes from the RB4/TCLK12 pin, which can also be selected to be the clock for the TMR1 module. TMR1 can be concatenated to TMR2 to form a 16-bit timer. The TMR2 register is the MSB and TMR1 is the LSB. When in the 16-bit timer mode, there is a corresponding 16-bit period register (PR2:PR1). When the TMR2:TMR1 value rolls over from the period match value to 0h, the TMR1IF flag is set, and an interrupt will be generated when enabled.
The PIC17C4X has four timer modules. Each module can generate an interrupt to indicate that an event has occurred. These timers are called: * Timer0 - 16-bit timer with programmable 8-bit prescaler * Timer1 - 8-bit timer * Timer2 - 8-bit timer * Timer3 - 16-bit timer For enhanced time-base functionality, two input Captures and two Pulse Width Modulation (PWM) outputs are possible. The PWMs use the TMR1 and TMR2 resources and the input Captures use the TMR3 resource.
10.1
Timer0 Overview
10.4
Timer3 Overview
The Timer0 module is a simple 16-bit overflow counter. The clock source can be either the internal system clock (Fosc/4) or an external clock. The Timer0 module also has a programmable prescaler option. The PS3:PS0 bits (T0STA<4:1>) determine the prescaler value. TMR0 can increment at the following rates: 1:1, 1:2, 1:4, 1:8, 1:16, 1:32, 1:64, 1:128, 1:256. When TImer0's clock source is an external clock, the Timer0 module can be selected to increment on either the rising or falling edge. Synchronization of the external clock occurs after the prescaler. When the prescaler is used, the external clock frequency may be higher then the device's frequency. The maximum frequency is 50 MHz, given the high and low time requirements of the clock.
The TImer3 module is a 16-bit timer/counter with a 16bit period register. When the TMR3H:TMR3L value rolls over to 0h, the TMR3IF bit is set and an interrupt will be generated when enabled. In counter mode, the clock comes from the RB5/TCLK3 pin. When operating in the dual capture mode, the period registers become the second 16-bit capture register.
10.5
Role of the Timer/Counters
The timer modules are general purpose, but have dedicated resources associated with them. TImer1 and Timer2 are the time-bases for the two Pulse Width Modulation (PWM) outputs, while Timer3 is the timebase for the two input captures.
10.2
Timer1 Overview
The TImer0 module is an 8-bit timer/counter with an 8bit period register (PR1). When the TMR1 value rolls over from the period match value to 0h, the TMR1IF flag is set, and an interrupt will be generated when enabled. In counter mode, the clock comes from the RB4/TCLK12 pin, which can also be selected to be the clock for the Timer2 module. TMR1 can be concatenated to TMR2 to form a 16-bit timer. The TMR1 register is the LSB and TMR2 is the MSB. When in the 16-bit timer mode, there is a corresponding 16-bit period register (PR2:PR1). When the TMR2:TMR1 value rolls over from the period match value to 0h, the TMR1IF flag is set, and an interrupt will be generated when enabled.
(c) 1996 Microchip Technology Inc.
DS30412C-page 65
This document was created with FrameMaker 4 0 4
PIC17C4X
NOTES:
DS30412C-page 66
(c) 1996 Microchip Technology Inc.
PIC17C4X
11.0 TIMER0
The Timer0 module consists of a 16-bit timer/counter, TMR0. The high byte is TMR0H and the low byte is TMR0L. A software programmable 8-bit prescaler makes an effective 24-bit overflow timer. The clock source is also software programmable as either the internal instruction clock or the RA1/T0CKI pin. The control bits for this module are in register T0STA (Figure 11-1).
FIGURE 11-1: T0STA REGISTER (ADDRESS: 05h, UNBANKED)
R/W - 0 INTEDG bit7 R/W - 0 T0SE R/W - 0 T0CS R/W - 0 PS3 R/W - 0 PS2 R/W - 0 PS1 R/W - 0 PS0 U-0 -- bit0
R = Readable bit W = Writable bit U = Unimplemented, Read as '0' -n = Value at POR reset
bit 7:
INTEDG: RA0/INT Pin Interrupt Edge Select bit This bit selects the edge upon which the interrupt is detected 1 = Rising edge of RA0/INT pin generates interrupt 0 = Falling edge of RA0/INT pin generates interrupt T0SE: Timer0 Clock Input Edge Select bit This bit selects the edge upon which TMR0 will increment When T0CS = 0 1 = Rising edge of RA1/T0CKI pin increments TMR0 and/or generates a T0CKIF interrupt 0 = Falling edge of RA1/T0CKI pin increments TMR0 and/or generates a T0CKIF interrupt When T0CS = 1 Don't care T0CS: Timer0 Clock Source Select bit This bit selects the clock source for TMR0. 1 = Internal instruction clock cycle (TCY) 0 = T0CKI pin
bit 6:
bit 5:
bit 4-1: PS3:PS0: Timer0 Prescale Selection bits These bits select the prescale value for TMR0. PS3:PS0 0000 0001 0010 0011 0100 0101 0110 0111 1xxx bit 0: Prescale Value 1:1 1:2 1:4 1:8 1:16 1:32 1:64 1:128 1:256
Unimplemented: Read as '0'
(c) 1996 Microchip Technology Inc.
DS30412C-page 67
This document was created with FrameMaker 4 0 4
PIC17C4X
11.1 Timer0 Operation 11.2 Using Timer0 with External Clock
When the T0CS (T0STA<5>) bit is set, TMR0 increments on the internal clock. When T0CS is clear, TMR0 increments on the external clock (RA1/T0CKI pin). The external clock edge can be configured in software. When the T0SE (T0STA<6>) bit is set, the timer will increment on the rising edge of the RA1/T0CKI pin. When T0SE is clear, the timer will increment on the falling edge of the RA1/T0CKI pin. The prescaler can be programmed to introduce a prescale of 1:1 to 1:256. The timer increments from 0000h to FFFFh and rolls over to 0000h. On overflow, the TMR0 Interrupt Flag bit (T0IF) is set. The TMR0 interrupt can be masked by clearing the corresponding TMR0 Interrupt Enable bit (T0IE). The TMR0 Interrupt Flag bit (T0IF) is automatically cleared when vectoring to the TMR0 interrupt vector. When the external clock input is used for Timer0, it is synchronized with the internal phase clocks. Figure 11-3 shows the synchronization of the external clock. This synchronization is done after the prescaler. The output of the prescaler (PSOUT) is sampled twice in every instruction cycle to detect a rising or a falling edge. The timing requirements for the external clock are detailed in the electrical specification section for the desired device. 11.2.1 DELAY FROM EXTERNAL CLOCK EDGE
Since the prescaler output is synchronized with the internal clocks, there is a small delay from the time the external clock edge occurs to the time TMR0 is actually incremented. Figure 11-3 shows that this delay is between 3TOSC and 7TOSC. Thus, for example, measuring the interval between two edges (e.g. period) will be accurate within 4TOSC (121 ns @ 33 MHz).
FIGURE 11-2: TIMER0 MODULE BLOCK DIAGRAM
Interrupt on overflow sets T0IF (INTSTA<5>) Synchronization PSOUT TMR0H<8> TMR0L<8>
0 RA1/T0CKI T0SE (T0STA<6>) T0CS (T0STA<5>) Fosc/4 1
Prescaler (8 stage async ripple counter) 4 PS3:PS0 (T0STA<4:1>)
Q2
Q4
FIGURE 11-3: TMR0 TIMING WITH EXTERNAL CLOCK (INCREMENT ON FALLING EDGE)
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Prescaler output (PSOUT) Sampled Prescaler output (note 1) Increment TMR0
(note 3) (note 2)
TMR0
T0
T0 + 1
T0 + 2
Note 1: The delay from the T0CKI edge to the TMR0 increment is 3Tosc to 7Tosc. 2: = PSOUT is sampled here. 3: The PSOUT high time is too short and is missed by the sampling circuit.
DS30412C-page 68
(c) 1996 Microchip Technology Inc.
PIC17C4X
11.3 Read/Write Consideration for TMR0
11.3.2 WRITING A 16-BIT VALUE TO TMR0 Although TMR0 is a 16-bit timer/counter, only 8-bits at a time can be read or written during a single instruction cycle. Care must be taken during any read or write. 11.3.1 READING 16-BIT VALUE Since writing to either TMR0L or TMR0H will effectively inhibit increment of that half of the TMR0 in the next cycle (following write), but not inhibit increment of the other half, the user must write to TMR0L first and TMR0H next in two consecutive instructions, as shown in Example 11-2. The interrupt must be disabled. Any write to either TMR0L or TMR0H clears the prescaler.
The problem in reading the entire 16-bit value is that after reading the low (or high) byte, its value may change from FFh to 00h. Example 11-1 shows a 16-bit read. To ensure a proper read, interrupts must be disabled during this routine.
EXAMPLE 11-2: 16-BIT WRITE
BSF MOVFP MOVFP BCF CPUSTA, GLINTD RAM_L, TMR0L RAM_H, TMR0H CPUSTA, GLINTD ; Disable interrupt ; ; ; Done, enable interrupt
EXAMPLE 11-1: 16-BIT READ
MOVPF MOVPF MOVFP CPFSLT RETURN MOVPF MOVPF RETURN TMR0L, TMPLO TMR0H, TMPHI TMPLO, WREG TMR0L TMR0L, TMPLO TMR0H, TMPHI ;read low tmr0 ;read high tmr0 ;tmplo -> wreg ;tmr0l < wreg? ;no then return ;read low tmr0 ;read high tmr0 ;return
11.4
Prescaler Assignments
Timer0 has an 8-bit prescaler. The prescaler assignment is fully under software control; i.e., it can be changed "on the fly" during program execution. When changing the prescaler assignment, clearing the prescaler is recommended before changing assignment. The value of the prescaler is "unknown," and assigning a value that is less then the present value makes it difficult to take this unknown time into account.
FIGURE 11-4: TMR0 TIMING: WRITE HIGH OR LOW BYTE
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
AD15:AD0
PC
PC+1
PC+2
PC+3
PC+4
ALE T0 T0+1 New T0 (NT0) New T0+1
TMR0L Fetch Instruction executed TMR0H
MOVFP W,TMR0L MOVFP TMR0L,W MOVFP TMR0L,W MOVFP TMR0L,W Write to TMR0L Read TMR0L Read TMR0L Read TMR0L (Value = NT0) (Value = NT0) (Value = NT0 +1)
(c) 1996 Microchip Technology Inc.
DS30412C-page 69
PIC17C4X
FIGURE 11-5: TMR0 READ/WRITE IN TIMER MODE
Q1
Q2 Q3
Q4
Q1
Q2 Q3
Q4
Q1
Q2 Q3
Q4
Q1
Q2 Q3
Q4
Q1
Q2 Q3
Q4
Q1
Q2 Q3
Q4
AD15:AD0 ALE WR_TRM0L WR_TMR0H RD_TMR0L
TMR0H
12
12
13
AB
TMR0L
FE
FF
56
57
58
Instruction fetched
MOVFP MOVFP DATAL,TMR0L DATAH,TMR0H Write TMR0L Write TMR0H Previously Fetched Instruction
MOVPF TMR0L,W Read TMR0L
MOVPF TMR0L,W Read TMR0L MOVPF TMR0L,W Read TMR0L
MOVPF TMR0L,W Read TMR0L MOVPF TMR0L,W Read TMR0L
MOVPF TMR0L,W Read TMR0L MOVPF TMR0L,W Read TMR0L
Instruction executed
MOVFP MOVFP DATAL,TMR0L DATAH,TMR0H Write TMR0L Write TMR0H
In this example, old TMR0 value is 12FEh, new value of AB56h is written.
TABLE 11-1:
Address
REGISTERS/BITS ASSOCIATED WITH TIMER0
Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 000--11 11-0000 0000 xxxx xxxx xxxx xxxx Value on all other resets (Note1) 0000 000--11 qq-0000 0000 uuuu uuuu uuuu uuuu
05h, Unbanked 06h, Unbanked 07h, Unbanked 0Bh, Unbanked 0Ch, Unbanked Legend: Note 1:
T0STA CPUSTA INTSTA TMR0L TMR0H
INTEDG -- PEIF
T0SE -- T0CKIF
T0CS STKAV T0IF
PS3 GLINTD INTF
PS2 TO PEIE
PS1 PD T0CKIE
PS0 -- T0IE
-- -- INTE
TMR0 register; low byte TMR0 register; high byte
x = unknown, u = unchanged, - = unimplemented read as a '0', q - value depends on condition, Shaded cells are not used by Timer0. Other (non power-up) resets include: external reset through MCLR and the Watchdog Timer Reset.
DS30412C-page 70
(c) 1996 Microchip Technology Inc.
PIC17C4X
12.0 TIMER1, TIMER2, TIMER3, PWMS AND CAPTURES
Timer3 is a 16-bit timer/counter consisting of the TMR3H and TMR3L registers. This timer has four other associated registers. Two registers are used as a 16-bit period register or a 16-bit Capture1 register (PR3H/CA1H:PR3L/CA1L). The other two registers are strictly the Capture2 registers (CA2H:CA2L). Timer3 is the time-base for the two 16-bit captures. TMR3 can be software configured to increment from the internal system clock or from an external signal on the RB5/TCLK3 pin. Figure 12-1 and Figure 12-2 are the control registers for the operation of Timer1, Timer2, and Timer3, as well as PWM1, PWM2, Capture1, and Capture2.
The PIC17C4X has a wealth of timers and time-based functions to ease the implementation of control applications. These time-base functions include two PWM outputs and two Capture inputs. Timer1 and Timer2 are two 8-bit incrementing timers, each with a period register (PR1 and PR2 respectively) and separate overflow interrupt flags. Timer1 and Timer2 can operate either as timers (increment on internal Fosc/4 clock) or as counters (increment on falling edge of external clock on pin RB4/TCLK12). They are also software configurable to operate as a single 16-bit timer. These timers are also used as the time-base for the PWM (pulse width modulation) module.
FIGURE 12-1: TCON1 REGISTER (ADDRESS: 16h, BANK 3)
R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 CA2ED1 CA2ED0 CA1ED1 CA1ED0 T16 TMR3CS TMR2CS TMR1CS bit7 bit0 bit 7-6: CA2ED1:CA2ED0: Capture2 Mode Select bits 00 = Capture on every falling edge 01 = Capture on every rising edge 10 = Capture on every 4th rising edge 11 = Capture on every 16th rising edge bit 5-4: CA1ED1:CA1ED0: Capture1 Mode Select bits 00 = Capture on every falling edge 01 = Capture on every rising edge 10 = Capture on every 4th rising edge 11 = Capture on every 16th rising edge bit 3: T16: Timer1:Timer2 Mode Select bit 1 = Timer1 and Timer2 form a 16-bit timer 0 = Timer1 and Timer2 are two 8-bit timers TMR3CS: Timer3 Clock Source Select bit 1 = TMR3 increments off the falling edge of the RB5/TCLK3 pin 0 = TMR3 increments off the internal clock TMR2CS: Timer2 Clock Source Select bit 1 = TMR2 increments off the falling edge of the RB4/TCLK12 pin 0 = TMR2 increments off the internal clock TMR1CS: Timer1 Clock Source Select bit 1 = TMR1 increments off the falling edge of the RB4/TCLK12 pin 0 = TMR1 increments off the internal clock
R = Readable bit W = Writable bit -n = Value at POR reset
bit 2:
bit 1:
bit 0:
(c) 1996 Microchip Technology Inc.
DS30412C-page 71
This document was created with FrameMaker 4 0 4
PIC17C4X
FIGURE 12-2: TCON2 REGISTER (ADDRESS: 17h, BANK 3)
R-0 R-0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 R/W - 0 CA2OVF CA1OVF PWM2ON PWM1ON CA1/PR3 TMR3ON TMR2ON TMR1ON bit7 bit0 bit 7:
R = Readable bit W = Writable bit -n = Value at POR reset
CA2OVF: Capture2 Overflow Status bit This bit indicates that the capture value had not been read from the capture register pair (CA2H:CA2L) before the next capture event occurred. The capture register retains the oldest unread capture value (last capture before overflow). Subsequent capture events will not update the capture register with the Timer3 value until the capture register has been read (both bytes). 1 = Overflow occurred on Capture2 register 0 = No overflow occurred on Capture2 register CA1OVF: Capture1 Overflow Status bit This bit indicates that the capture value had not been read from the capture register pair (PR3H/CA2H:PR3L/CA2L) before the next capture event occurred. The capture register retains the oldest unread capture value (last capture before overflow). Subsequent capture events will not update the capture register with the TMR3 value until the capture register has been read (both bytes). 1 = Overflow occurred on Capture1 register 0 = No overflow occurred on Capture1 register PWM2ON: PWM2 On bit 1 = PWM2 is enabled (The RB3/PWM2 pin ignores the state of the DDRB<3> bit) 0 = PWM2 is disabled (The RB3/PWM2 pin uses the state of the DDRB<3> bit for data direction) PWM1ON: PWM1 On bit 1 = PWM1 is enabled (The RB2/PWM1 pin ignores the state of the DDRB<2> bit) 0 = PWM1 is disabled (The RB2/PWM1 pin uses the state of the DDRB<2> bit for data direction) CA1/PR3: CA1/PR3 Register Mode Select bit 1 = Enables Capture1 (PR3H/CA1H:PR3L/CA1L is the Capture1 register. Timer3 runs without a period register) 0 = Enables the Period register (PR3H/CA1H:PR3L/CA1L is the Period register for Timer3) TMR3ON: Timer3 On bit 1 = Starts Timer3 0 = Stops Timer3 TMR2ON: Timer2 On bit This bit controls the incrementing of the Timer2 register. When Timer2:Timer1 form the 16-bit timer (T16 is set), TMR2ON must be set. This allows the MSB of the timer to increment. 1 = Starts Timer2 (Must be enabled if the T16 bit (TCON1<3>) is set) 0 = Stops Timer2 TMR1ON: Timer1 On bit When T16 is set (in 16-bit Timer Mode) 1 = Starts 16-bit Timer2:Timer1 0 = Stops 16-bit Timer2:Timer1 When T16 is clear (in 8-bit Timer Mode) 1 = Starts 8-bit Timer1 0 = Stops 8-bit Timer1
bit 6:
bit 5:
bit 4:
bit 3:
bit 2:
bit 1:
bit 0:
DS30412C-page 72
(c) 1996 Microchip Technology Inc.
PIC17C4X
12.1
12.1.1
Timer1 and Timer2
TIMER1, TIMER2 IN 8-BIT MODE
12.1.1.1
EXTERNAL CLOCK INPUT FOR TIMER1 OR TIMER2
Both Timer1 and Timer2 will operate in 8-bit mode when the T16 bit is clear. These two timers can be independently configured to increment from the internal instruction cycle clock or from an external clock source on the RB4/TCLK12 pin. The timer clock source is configured by the TMRxCS bit (x = 1 for Timer1 or = 2 for Timer2). When TMRxCS is clear, the clock source is internal and increments once every instruction cycle (Fosc/4). When TMRxCS is set, the clock source is the RB4/TCLK12 pin, and the timer will increment on every falling edge of the RB4/TCLK12 pin. The timer increments from 00h until it equals the Period register (PRx). It then resets to 00h at the next increment cycle. The timer interrupt flag is set when the timer is reset. TMR1 and TMR2 have individual interrupt flag bits. The TMR1 interrupt flag bit is latched into TMR1IF, and the TMR2 interrupt flag bit is latched into TMR2IF. Each timer also has a corresponding interrupt enable bit (TMRxIE). The timer interrupt can be enabled by setting this bit and disabled by clearing this bit. For peripheral interrupts to be enabled, the Peripheral Interrupt Enable bit must be enabled (PEIE is set) and global interrupts must be enabled (GLINTD is cleared). The timers can be turned on and off under software control. When the Timerx On control bit (TMRxON) is set, the timer increments from the clock source. When TMRxON is cleared, the timer is turned off and cannot cause the timer interrupt flag to be set.
When TMRxCS is set, the clock source is the RB4/TCLK12 pin, and the timer will increment on every falling edge on the RB4/TCLK12 pin. The TCLK12 input is synchronized with internal phase clocks. This causes a delay from the time a falling edge appears on TCLK12 to the time TMR1 or TMR2 is actually incremented. For the external clock input timing requirements, see the Electrical Specification section.
FIGURE 12-3: TIMER1 AND TIMER2 IN TWO 8-BIT TIMER/COUNTER MODE
Fosc/4 0 TMR1 1 TMR1ON (TCON2<0>) TMR1CS (TCON1<0>) Comparator<8> Comparator x8 PR1 Equal
Reset Set TMR1IF (PIR<4>)
RB4/TCLK12
1 TMR2 Fosc/4 0 TMR2ON (TCON2<1>) TMR2CS (TCON1<1>) Comparator<8> Comparator x8 PR2
Reset Set TMR2IF (PIR<5>) Equal
(c) 1996 Microchip Technology Inc.
DS30412C-page 73
PIC17C4X
12.1.2 TIMER1 & TIMER2 IN 16-BIT MODE 12.1.2.1 To select 16-bit mode, the T16 bit must be set. In this mode TMR1 and TMR2 are concatenated to form a 16-bit timer (TMR2:TMR1). The 16-bit timer increments until it matches the 16-bit period register (PR2:PR1). On the following timer clock, the timer value is reset to 0h, and the TMR1IF bit is set. When selecting the clock source for the16-bit timer, the TMR1CS bit controls the entire 16-bit timer and TMR2CS is a "don't care." When TMR1CS is clear, the timer increments once every instruction cycle (Fosc/4). When TMR1CS is set, the timer increments on every falling edge of the RB4/TCLK12 pin. For the 16-bit timer to increment, both TMR1ON and TMR2ON bits must be set (Table 12-1). EXTERNAL CLOCK INPUT FOR TMR1:TMR2
When TMR1CS is set, the 16-bit TMR2:TMR1 increments on the falling edge of clock input TCLK12. The input on the RB4/TCLK12 pin is sampled and synchronized by the internal phase clocks twice every instruction cycle. This causes a delay from the time a falling edge appears on RB4/TCLK12 to the time TMR2:TMR1 is actually incremented. For the external clock input timing requirements, see the Electrical Specification section.
TABLE 12-1:
TMR2ON 1
TURNING ON 16-BIT TIMER
TMR1ON 1 Result 16-bit timer (TMR2:TMR1) ON Only TMR1 increments 16-bit timer OFF
0 x
1 0
FIGURE 12-4: TMR1 AND TMR2 IN 16-BIT TIMER/COUNTER MODE
1 RB4/TCLK12 TMR2 x 8 Fosc/4 0 TMR1ON (TCON2<0>) TMR1CS (TCON1<0>) Comparator<8> Comparator x16 PR2 x 8 PR1 x 8 Equal TMR1 x 8 Reset Set Interrupt TMR1IF (PIR<4>)
TABLE 12-2:
Address
SUMMARY OF TIMER1 AND TIMER2 REGISTERS
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset Value on all other resets (Note1) 0000 0000 0000 0000 uuuu uuuu uuuu uuuu 0000 0010 0000 0000 0000 0000 --11 qq-uuuu uuuu uuuu uuuu uu-- ---uu0- ---uuuu uuuu uuuu uuuu
Name
16h, Bank 3 17h, Bank 3 10h, Bank 2 11h, Bank 2 16h, Bank 1 17h, Bank 1
TCON1 TCON2 TMR1 TMR2 PIR PIE
CA2ED1
CA2ED0
CA1ED1
CA1ED0
T16
TMR3CS TMR2CS TMR1CS 0000 0000
CA2OVF CA1OVF PWM2ON PWM1ON CA1/PR3 TMR3ON TMR2ON TMR1ON 0000 0000 Timer1 register Timer2 register RBIF RBIE PEIF -- TMR3IF TMR3IE T0CKIF -- TMR2IF TMR2IE T0IF STKAV TMR1IF TMR1IE INTF GLINTD CA2IF CA2IE PEIE TO CA1IF CA1IE T0CKIE PD TXIF TXIE T0IE -- RCIF RCIE INTE -- xxxx xxxx xxxx xxxx 0000 0010 0000 0000 0000 0000 --11 11-xxxx xxxx xxxx xxxx -- TM2PW2 DC7 DC7 -- -- DC6 DC6 -- -- DC5 DC5 -- -- DC4 DC4 -- -- DC3 DC3 -- -- DC2 DC2 xx-- ---xx0- ---xxxx xxxx xxxx xxxx
07h, Unbanked INTSTA 06h, Unbanked CPUSTA 14h, Bank 2 15h, Bank 2 10h, Bank 3 11h, Bank 3 12h, Bank 3 13h, Bank 3 PR1 PR2 PW1DCL PW2DCL PW1DCH PW2DCH
Timer1 period register Timer2 period register DC1 DC1 DC9 DC9 DC0 DC0 DC8 DC8
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', q - value depends on condition, shaded cells are not used by Timer1 or Timer2. Note 1: Other (non power-up) resets include: external reset through MCLR and WDT Timer Reset.
DS30412C-page 74
(c) 1996 Microchip Technology Inc.
PIC17C4X
12.1.3 USING PULSE WIDTH MODULATION (PWM) OUTPUTS WITH TMR1 AND TMR2
FIGURE 12-5: SIMPLIFIED PWM BLOCK DIAGRAM
Duty Cycle registers PWxDCH PWxDCL<7:6> Write
Two high speed pulse width modulation (PWM) outputs are provided. The PWM1 output uses Timer1 as its time-base, while PWM2 may be software configured to use either Timer1 or Timer2 as the time-base. The PWM outputs are on the RB2/PWM1 and RB3/PWM2 pins. Each PWM output has a maximum resolution of 10-bits. At 10-bit resolution, the PWM output frequency is 24.4 kHz (@ 25 MHz clock) and at 8-bit resolution the PWM output frequency is 97.7 kHz. The duty cycle of the output can vary from 0% to 100%. Figure 12-5 shows a simplified block diagram of the PWM module. The duty cycle register is double buffered for glitch free operation. Figure 12-6 shows how a glitch could occur if the duty cycle registers were not double buffered. The user needs to set the PWM1ON bit (TCON2<4>) to enable the PWM1 output. When the PWM1ON bit is set, the RB2/PWM1 pin is configured as PWM1 output and forced as an output irrespective of the data direction bit (DDRB<2>). When the PWM1ON bit is clear, the pin behaves as a port pin and its direction is controlled by its data direction bit (DDRB<2>). Similarly, the PWM2ON (TCON2<5>) bit controls the configuration of the RB3/PWM2 pin.
(Slave) Comparator TMR2 Comparator PRy (Note 1)
Read RCy/PWMx R S Q PWMxON
Clear Timer, PWMx pin and Latch D.C.
Note 1: 8-bit timer is concatenated with 2-bit internal Q clock or 2 bits of the prescaler to create 10-bit time-base.
FIGURE 12-6: PWM OUTPUT
0
10
20
30
40
0
PWM output
Timer interrupt Note
Write new PWM value
Timer interrupt new PWM value transferred to slave
The dotted line shows PWM output if duty cycle registers were not double buffered. If the new duty cycle is written after the timer has passed that value, then the PWM does not reset at all during the current cycle causing a "glitch". In this example, PWM period = 50. Old duty cycle is 30. New duty cycle value is 10.
(c) 1996 Microchip Technology Inc.
DS30412C-page 75
PIC17C4X
12.1.3.1 PWM PERIODS The period of the PWM1 output is determined by Timer1 and its period register (PR1). The period of the PWM2 output can be software configured to use either Timer1 or Timer2 as the time-base. When TM2PW2 bit (PW2DCL<5>) is clear, the time-base is determined by TMR1 and PR1. When TM2PW2 is set, the time-base is determined by Timer2 and PR2. Running two different PWM outputs on two different timers allows different PWM periods. Running both PWMs from Timer1 allows the best use of resources by freeing Timer2 to operate as an 8-bit timer. Timer1 and Timer2 can not be used as a 16-bit timer if either PWM is being used. The PWM periods can be calculated as follows: period of PWM1 =[(PR1) + 1] x 4TOSC period of PWM2 =[(PR1) + 1] x 4TOSC or [(PR2) + 1] x 4TOSC The duty cycle of PWMx is determined by the 10-bit value DCx<9:0>. The upper 8-bits are from register PWxDCH and the lower 2-bits are from PWxDCL<7:6> (PWxDCH:PWxDCL<7:6>). Table 12-3 shows the maximum PWM frequency (FPWM) given the value in the period register. The number of bits of resolution that the PWM can achieve depends on the operation frequency of the device as well as the PWM frequency (FPWM). Maximum PWM resolution (bits) for a given PWM frequency: log FOSC ( FPWM ) bits log (2) The PWMx duty cycle is as follows: PWMx Duty Cycle = where DCx represents PWxDCH:PWxDCL. (DCx) x TOSC the 10-bit value from The user should also avoid any "read-modify-write" operations on the duty cycle registers, such as: ADDWF PW1DCH. This may cause duty cycle outputs that are unpredictable.
TABLE 12-3:
PWM FREQUENCY vs. RESOLUTION AT 25 MHz
Frequency (kHz) 24.4 48.8 65.104 97.66 0x3F 8-bit 6-bit 390.6 0x0F 6-bit 4-bit
PWM Frequency PRx Value High Resolution Standard Resolution 12.1.3.2
0xFF 10-bit 8-bit
0x7F 0x5F 9-bit 8.5-bit 7-bit 6.5-bit
PWM INTERRUPTS
The PWM module makes use of TMR1 or TMR2 interrupts. A timer interrupt is generated when TMR1 or TMR2 equals its period register and is cleared to zero. This interrupt also marks the beginning of a PWM cycle. The user can write new duty cycle values before the timer roll-over. The TMR1 interrupt is latched into the TMR1IF bit and the TMR2 interrupt is latched into the TMR2IF bit. These flags must be cleared in software. 12.1.3.3 EXTERNAL CLOCK SOURCE
=
The PWMs will operate regardless of the clock source of the timer. The use of an external clock has ramifications that must be understood. Because the external TCLK12 input is synchronized internally (sampled once per instruction cycle), the time TCLK12 changes to the time the timer increments will vary by as much as TCY (one instruction cycle). This will cause jitter in the duty cycle as well as the period of the PWM output. This jitter will be TCY, unless the external clock is synchronized with the processor clock. Use of one of the PWM outputs as the clock source to the TCLKx input, will supply a synchronized clock. In general, when using an external clock source for PWM, its frequency should be much less than the device frequency (Fosc).
If DCx = 0, then the duty cycle is zero. If PRx = PWxDCH, then the PWM output will be low for one to four Q-clock (depending on the state of the PWxDCL<7:6> bits). For a Duty Cycle to be 100%, the PWxDCH value must be greater then the PRx value. The duty cycle registers for both PWM outputs are double buffered. When the user writes to these registers, they are stored in master latches. When TMR1 (or TMR2) overflows and a new PWM period begins, the master latch values are transferred to the slave latches and the PWMx pin is forced high. Note: For PW1DCH, PW1DCL, PW2DCH and PW2DCL registers, a write operation writes to the "master latches" while a read operation reads the "slave latches". As a result, the user may not read back what was just written to the duty cycle registers.
DS30412C-page 76
(c) 1996 Microchip Technology Inc.
PIC17C4X
12.1.3.3.1 MAX RESOLUTION/FREQUENCY FOR EXTERNAL CLOCK INPUT The use of an external clock for the PWM time-base (Timer1 or Timer2) limits the PWM output to a maximum resolution of 8-bits. The PWxDCL<7:6> bits must be kept cleared. Use of any other value will distort the PWM output. All resolutions are supported when internal clock mode is selected. The maximum attainable frequency is also lower. This is a result of the timing requirements of an external clock input for a timer (see the Electrical Specification section). The maximum PWM frequency, when the timers clock source is the RB4/TCLK12 pin, is shown in Table 12-3 (standard resolution mode). Timer3 has two modes of operation, depending on the CA1/PR3 bit (TCON2<3>). These modes are: * One capture and one period register mode * Dual capture register mode The PIC17C4X has up to two 16-bit capture registers that capture the 16-bit value of TMR3 when events are detected on capture pins. There are two capture pins (RB0/CAP1 and RB1/CAP2), one for each capture register. The capture pins are multiplexed with PORTB pins. An event can be: * * * * a rising edge a falling edge every 4th rising edge every 16th rising edge
12.2
Timer3
Timer3 is a 16-bit timer consisting of the TMR3H and TMR3L registers. TMR3H is the high byte of the timer and TMR3L is the low byte. This timer has an associated 16-bit period register (PR3H/CA1H:PR3L/CA1L). This period register can be software configured to be a second 16-bit capture register. When the TMR3CS bit (TCON1<2>) is clear, the timer increments every instruction cycle (Fosc/4). When TMR3CS is set, the timer increments on every falling edge of the RB5/TCLK3 pin. In either mode, the TMR3ON bit must be set for the timer to increment. When TMR3ON is clear, the timer will not increment or set the TMR3IF bit.
Each 16-bit capture register has an interrupt flag associated with it. The flag is set when a capture is made. The capture module is truly part of the Timer3 block. Figure 12-7 and Figure 12-8 show the block diagrams for the two modes of operation.
TABLE 12-4:
Address
REGISTERS/BITS ASSOCIATED WITH PWM
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 0000 0000 0000 xxxx xxxx xxxx xxxx TMR2IF TMR2IE T0IF STKAV -- TM2PW2 DC7 DC7 TMR1IF TMR1IE INTF GLINTD -- -- DC6 DC6 CA2IF CA2IE PEIE TO -- -- DC5 DC5 CA1IF CA1IE T0CKIE PD -- -- DC4 DC4 TXIF TXIE T0IE -- -- -- DC3 DC3 RCIF RCIE INTE -- -- -- DC2 DC2 0000 0010 0000 0000 0000 0000 --11 11-xx-- ---xx0- ---xxxx xxxx xxxx xxxx Value on all other resets (Note1) 0000 0000 0000 0000 uuuu uuuu uuuu uuuu 0000 0010 0000 0000 0000 0000 --11 qq-uu-- ---uu0- ---uuuu uuuu uuuu uuuu
Name
16h, Bank 3 17h, Bank 3 10h, Bank 2 11h, Bank 2 16h, Bank 1 17h, Bank 1
TCON1 TCON2 TMR1 TMR2 PIR PIE
CA2ED1 CA2OVF
CA2ED0 CA1OVF
CA1ED1 PWM2ON
CA1ED0 PWM1ON
T16
TMR3CS
TMR2CS
TMR1CS
CA1/PR3 TMR3ON TMR2ON TMR1ON
Timer1 register Timer2 register RBIF RBIE PEIF -- DC1 DC1 DC9 DC9 TMR3IF TMR3IE T0CKIF -- DC0 DC0 DC8 DC8
07h, Unbanked INTSTA 06h, Unbanked CPUSTA 10h, Bank 3 11h, Bank 3 12h, Bank 3 13h, Bank 3 PW1DCL PW2DCL PW1DCH PW2DCH
Legend: x = unknown, u = unchanged, - = unimplemented read as '0', q = value depends on conditions, shaded cells are not used by PWM.
(c) 1996 Microchip Technology Inc.
DS30412C-page 77
PIC17C4X
12.2.1 ONE CAPTURE AND ONE PERIOD REGISTER MODE Capture pin RB1/CAP2 is a multiplexed pin. When used as a port pin, Capture2 is not disabled. However, the user can simply disable the Capture2 interrupt by clearing CA2IE. If RB1/CAP2 is used as an output pin, the user can activate a capture by writing to the port pin. This may be useful during development phase to emulate a capture interrupt. The input on capture pin RB1/CAP2 is synchronized internally to internal phase clocks. This imposes certain restrictions on the input waveform (see the Electrical Specification section for timing). The Capture2 overflow status flag bit is double buffered. The master bit is set if one captured word is already residing in the Capture2 register and another "event" has occurred on the RB1/CA2 pin. The new event will not transfer the Timer3 value to the capture register, protecting the previous unread capture value. When the user reads both the high and the low bytes (in any order) of the Capture2 register, the master overflow bit is transferred to the slave overflow bit (CA2OVF) and then the master bit is reset. The user can then read TCON2 to determine the value of CA2OVF. The recommended sequence to read capture registers and capture overflow flag bits is shown in Example 12-1.
In this mode registers PR3H/CA1H and PR3L/CA1L constitute a 16-bit period register. A block diagram is shown in Figure 12-7. The timer increments until it equals the period register and then resets to 0000h. TMR3 Interrupt Flag bit (TMR3IF) is set at this point. This interrupt can be disabled by clearing the TMR3 Interrupt Enable bit (TMR3IE). TMR3IF must be cleared in software. This mode is selected if control bit CA1/PR3 is clear. In this mode, the Capture1 register, consisting of high byte (PR3H/CA1H) and low byte (PR3L/CA1L), is configured as the period control register for TMR3. Capture1 is disabled in this mode, and the corresponding Interrupt bit CA1IF is never set. TMR3 increments until it equals the value in the period register and then resets to 0000h. Capture2 is active in this mode. The CA2ED1 and CA2ED0 bits determine the event on which capture will occur. The possible events are: * * * * Capture on every falling edge Capture on every rising edge Capture every 4th rising edge Capture every 16th rising edge
When a capture takes place, an interrupt flag is latched into the CA2IF bit. This interrupt can be enabled by setting the corresponding mask bit CA2IE. The Peripheral Interrupt Enable bit (PEIE) must be set and the Global Interrupt Disable bit (GLINTD) must be cleared for the interrupt to be acknowledged. The CA2IF interrupt flag bit must be cleared in software. When the capture prescale select is changed, the prescaler is not reset and an event may be generated. Therefore, the first capture after such a change will be ambiguous. However, it sets the time-base for the next capture. The prescaler is reset upon chip reset.
EXAMPLE 12-1: SEQUENCE TO READ CAPTURE REGISTERS
MOVLB 3 MOVPF CA2L,LO_BYTE ;Select Bank 3 ;Read Capture2 low ;byte, store in LO_BYTE MOVPF CA2H,HI_BYTE ;Read Capture2 high ;byte, store in HI_BYTE MOVPF TCON2,STAT_VAL ;Read TCON2 into file ;STAT_VAL
FIGURE 12-7: TIMER3 WITH ONE CAPTURE AND ONE PERIOD REGISTER BLOCK DIAGRAM
TMR3CS (TCON1<2>) Fosc/4 0 1 RB5/TCLK3 TMR3H TMR3ON (TCON2<2>) Capture1 Enable TMR3L PR3H/CA1H PR3L/CA1L Set TMR3IF (PIR<6>) Equal Reset
Comparator x16 Comparator<8>
Edge select prescaler select RB1/CAP2 2 CA2ED1: CA2ED0 (TCON1<7:6>)
CA2H
CA2L
Set CA2IF (PIR<3>)
DS30412C-page 78
(c) 1996 Microchip Technology Inc.
PIC17C4X
12.2.2 DUAL CAPTURE REGISTER MODE This mode is selected by setting CA1/PR3. A block diagram is shown in Figure 12-8. In this mode, TMR3 runs without a period register and increments from 0000h to FFFFh and rolls over to 0000h. The TMR3 interrupt Flag (TMR3IF) is set on this roll over. The TMR3IF bit must be cleared in software. Registers PR3H/CA1H and PR3L/CA1L make a 16-bit capture register (Capture1). It captures events on pin RB0/CAP1. Capture mode is configured by the CA1ED1 and CA1ED0 bits. Capture1 Interrupt Flag bit (CA1IF) is set on the capture event. The corresponding interrupt mask bit is CA1IE. The Capture1 Overflow Status bit is CA1OVF. The Capture2 overflow status flag bit is double buffered. The master bit is set if one captured word is already residing in the Capture2 register and another "event" has occurred on the RB1/CA2 pin. The new event will not transfer the TMR3 value to the capture register which protects the previous unread capture value. When the user reads both the high and the low bytes (in any order) of the Capture2 register, the master overflow bit is transferred to the slave overflow bit (CA2OVF) and then the master bit is reset. The user can then read TCON2 to determine the value of CA2OVF. The operation of the Capture1 feature is identical to Capture2 (as described in Section 12.2.1).
FIGURE 12-8: TIMER3 WITH TWO CAPTURE REGISTERS BLOCK DIAGRAM
CA1ED1, CA1ED0 2 (TCON1<5:4>) Edge Select Prescaler Select RB0/CAP1 Fosc/4 0 1 RB5/TCLK3 TMR3ON (TCON2<2>) TMR3CS (TCON1<2>) Edge Select Prescaler Select RB1/CAP2 2 CA2ED1, CA2ED0 (TCON1<7:6>) TMR3H Capture Enable TMR3L PR3H/CA1H Capture Enable Set TMR3IF (PIR<6>) PR3L/CA1L Set CA1IF (PIR<2>)
CA2H
CA2L
Set CA2IF (PIR<3>)
TABLE 12-5:
Address
REGISTERS ASSOCIATED WITH CAPTURE
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset Value on all other resets (Note1) 0000 0000 0000 0000 uuuu uuuu uuuu uuuu 0000 0010 0000 0000 0000 0000 --11 qq-uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu
Name
16h, Bank 3 17h, Bank 3 12h, Bank 2 13h, Bank 2 16h, Bank 1 17h, Bank 1
TCON1 TCON2 TMR3L TMR3H PIR PIE
CA2ED1 CA2ED0 CA2OVF CA1OVF
CA1ED1 PWM2ON
CA1ED0
T16
TMR3CS TMR2CS TMR1CS 0000 0000
PWM1ON CA1/PR3 TMR3ON TMR2ON TMR1ON 0000 0000 xxxx xxxx xxxx xxxx TMR1IF TMR1IE INTF GLINTD CA2IF CA2IE PEIE TO CA1IF CA1IE T0CKIE PD TXIF TXIE T0IE -- RCIF RCIE INTE -- 0000 0010 0000 0000 0000 0000 --11 11-xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
TMR3 register; low byte TMR3 register; high byte RBIF RBIE PEIF -- TMR3IF TMR3IE T0CKIF -- TMR2IF TMR2IE T0IF STKAV
07h, Unbanked INTSTA 06h, Unbanked CPUSTA 16h, Bank 2 17h, Bank 2 14h, Bank 3 15h, Bank 3 PR3L/CA1L
Timer3 period register, low byte/capture1 register, low byte
PR3H/CA1H Timer3 period register, high byte/capture1 register, high byte CA2L CA2H Capture2 low byte Capture2 high byte
Legend: x = unknown, u = unchanged, - = unimplemented read as '0', q - value depends on condition, shaded cells are not used by Capture. Note 1: Other (non power-up) resets include: external reset through MCLR and WDT Timer Reset.
(c) 1996 Microchip Technology Inc.
DS30412C-page 79
PIC17C4X
12.2.3 EXTERNAL CLOCK INPUT FOR TIMER3
EXAMPLE 12-2: WRITING TO TMR3
BSF MOVFP MOVFP BCF CPUSTA, RAM_L, RAM_H, CPUSTA, GLINTD TMR3L TMR3H GLINTD ;Disable interrupt ; ; ;Done,enable interrupt
When TMR3CS is set, the 16-bit TMR3 increments on the falling edge of clock input TCLK3. The input on the RB5/TCLK3 pin is sampled and synchronized by the internal phase clocks twice every instruction cycle. This causes a delay from the time a falling edge appears on TCLK3 to the time TMR3 is actually incremented. For the external clock input timing requirements, see the Electrical Specification section. Figure 12-9 shows the timing diagram when operating from an external clock. 12.2.4 READING/WRITING TIMER3
EXAMPLE 12-3: READING FROM TMR3
MOVPF MOVPF MOVFP CPFSLT RETURN MOVPF MOVPF RETURN TMR3L, TMR3H, TMPLO, TMR3L, TMPLO TMPHI WREG WREG ;read low tmr0 ;read high tmr0 ;tmplo -> wreg ;tmr0l < wreg? ;no then return ;read low tmr0 ;read high tmr0 ;return
Since Timer3 is a 16-bit timer and only 8-bits at a time can be read or written, care should be taken when reading or writing while the timer is running. The best method to read or write the timer is to stop the timer, perform any read or write operation, and then restart Timer3 (using the TMR3ON bit). However, if it is necessary to keep Timer3 free-running, care must be taken. For writing to the 16-bit TMR3, Example 12-2 may be used. For reading the 16-bit TMR3, Example 12-3 may be used. Interrupts must be disabled during this routine.
TMR3L, TMPLO TMR3H, TMPHI
FIGURE 12-9: TMR1, TMR2, AND TMR3 OPERATION IN EXTERNAL CLOCK MODE
Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
TCLK12 TMR1, TMR2, or TMR3 PR1, PR2, or PR3H:PR3L WR_TMR Read_TMR TMRxIF Instruction executed
MOVWF TMRx Write to TMRx MOVFP TMRx,W Read TMRx MOVFP TMRx,W Read TMRx
34h
35h
A8h
A9h
00h
'A9h'
'A9h'
Note 1: TCLK12 is sampled in Q2 and Q4. 2: indicates a sampling point. 3: The latency from TCLK12 to timer increment is between 2Tosc and 6Tosc.
DS30412C-page 80
(c) 1996 Microchip Technology Inc.
PIC17C4X
FIGURE 12-10: TMR1, TMR2, AND TMR3 OPERATION IN TIMER MODE
Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 Q1Q2 Q3 Q4 AD15:AD0 ALE Instruction fetched MOVF MOVWF MOVF TMR1, W TMR1 TMR1, W Read TMR1 Write TMR1 Read TMR1 MOVLB 3 BSF TCON2, 0 Stop TMR1 NOP BCF TCON2, 0 Start TMR1 NOP NOP NOP NOP
TMR1 PR1
04h
05h
03h
04h
05h
06h
07h
08h
00h
TMR1ON
WR_TMR1
WR_TCON2
TMR1IF
RD_TMR1 TMR1 reads 03h TMR1 reads 04h
TABLE 12-6:
Address
SUMMARY OF TMR1, TMR2, AND TMR3 REGISTERS
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset Value on all other resets (Note1) 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0010 0000 0000 0000 0000 --11 qq-uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uu-- ---uu0- ---uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu
Name
16h, Bank 3 17h, Bank 3 10h, Bank 2 11h, Bank 2 12h, Bank 2 13h, Bank 2 16h, Bank 1 17h, Bank 1
TCON1 TCON2 TMR1 TMR2 TMR3L TMR3H PIR PIE
CA2ED1
CA2ED0
CA1ED1
CA1ED0
T16
TMR3CS TMR2CS TMR1CS 0000 0000
CA2OVF CA1OVF PWM2ON PWM1ON CA1/PR3 TMR3ON TMR2ON TMR1ON 0000 0000 Timer1 register Timer2 register TMR3 register; low byte TMR3 register; high byte RBIF RBIE PEIF -- TMR3IF TMR3IE T0CKIF -- TMR2IF TMR2IE T0IF STKAV TMR1IF TMR1IE INTF GLINTD CA2IF CA2IE PEIE TO CA1IF CA1IE T0CKIE PD TXIF TXIE T0IE -- RCIF RCIE INTE -- xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx 0000 0010 0000 0000 0000 0000 --11 11-xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx -- -- DC5 DC5 -- -- DC4 DC4 -- -- DC3 DC3 -- -- DC2 DC2 xx-- ---xx0- ---xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
07h, Unbanked INTSTA 06h, Unbanked CPUSTA 14h, Bank 2 15h, Bank 2 16h, Bank 2 17h, Bank 2 10h, Bank 3 11h, Bank 3 12h, Bank 3 13h, Bank 3 14h, Bank 3 15h, Bank 3 PR1 PR2 PR3L/CA1L
Timer1 period register Timer2 period register Timer3 period/capture1 register; low byte
PR3H/CA1H Timer3 period/capture1 register; high byte PW1DCL PW2DCL PW1DCH PW2DCH CA2L CA2H DC1 DC1 DC9 DC9 DC0 DC0 DC8 DC8 -- TM2PW2 DC7 DC7 -- -- DC6 DC6
Capture2 low byte Capture2 high byte
Legend: x = unknown, u = unchanged, - = unimplemented read as '0', q - value depends on condition, shaded cells are not used by TMR1, TMR2 or TMR3. Note 1: Other (non power-up) resets include: external reset through MCLR and WDT Timer Reset.
(c) 1996 Microchip Technology Inc.
DS30412C-page 81
PIC17C4X
NOTES:
DS30412C-page 82
(c) 1996 Microchip Technology Inc.
PIC17C4X
13.0 UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER (USART) MODULE
The SPEN (RCSTA<7>) bit has to be set in order to configure RA4 and RA5 as the Serial Communication Interface. The USART module will control the direction of the RA4/RX/DT and RA5/TX/CK pins, depending on the states of the USART configuration bits in the RCSTA and TXSTA registers. The bits that control I/O direction are: * * * * * SPEN TXEN SREN CREN CSRC
The USART module is a serial I/O module. The USART can be configured as a full duplex asynchronous system that can communicate with peripheral devices such as CRT terminals and personal computers, or it can be configured as a half duplex synchronous system that can communicate with peripheral devices such as A/D or D/A integrated circuits, Serial EEPROMs etc. The USART can be configured in the following modes: * Asynchronous (full duplex) * Synchronous - Master (half duplex) * Synchronous - Slave (half duplex)
The Transmit Status And Control Register is shown in Figure 13-1, while the Receive Status And Control Register is shown in Figure 13-2.
FIGURE 13-1: TXSTA REGISTER (ADDRESS: 15h, BANK 0)
R/W - 0 R/W - 0 R/W - 0 R/W - 0 CSRC TX9 TXEN SYNC bit7 bit 7: U-0 -- U-0 -- R-1 TRMT R/W - x TX9D bit0
R = Readable bit W = Writable bit -n = Value at POR reset (x = unknown)
CSRC: Clock Source Select bit Synchronous mode: 1 = Master Mode (Clock generated internally from BRG) 0 = Slave mode (Clock from external source) Asynchronous mode: Don't care TX9: 9-bit Transmit Enable bit 1 = Selects 9-bit transmission 0 = Selects 8-bit transmission TXEN: Transmit Enable bit 1 = Transmit enabled 0 = Transmit disabled SREN/CREN overrides TXEN in SYNC mode SYNC: USART mode Select bit (Synchronous/Asynchronous) 1 = Synchronous mode 0 = Asynchronous mode TRMT: Transmit Shift Register (TSR) Empty bit 1 = TSR empty 0 = TSR full TX9D: 9th bit of transmit data (can be used to calculated the parity in software)
bit 6:
bit 5:
bit 4:
bit 3-2: Unimplemented: Read as '0' bit 1:
bit 0:
(c) 1996 Microchip Technology Inc.
DS30412C-page 83
This document was created with FrameMaker 4 0 4
PIC17C4X
FIGURE 13-2: RCSTA REGISTER (ADDRESS: 13h, BANK 0)
R/W - 0 R/W - 0 R/W - 0 R/W - 0 SPEN RX9 SREN CREN bit7 bit 7: U-0 -- R- 0 FERR R-0 OERR R-x RX9D bit 0
R = Readable bit W = Writable bit -n = Value at POR reset (x = unknown)
SPEN: Serial Port Enable bit 1 = Configures RA5/RX/DT and RA4/TX/CK pins as serial port pins 0 = Serial port disabled RX9: 9-bit Receive Enable bit 1 = Selects 9-bit reception 0 = Selects 8-bit reception SREN: Single Receive Enable bit This bit enables the reception of a single byte. After receiving the byte, this bit is automatically cleared. Synchronous mode: 1 = Enable reception 0 = Disable reception Note: This bit is ignored in synchronous slave reception. Asynchronous mode: Don't care CREN: Continuous Receive Enable bit This bit enables the continuous reception of serial data. Asynchronous mode: 1 = Enable reception 0 = Disables reception Synchronous mode: 1 = Enables continuous reception until CREN is cleared (CREN overrides SREN) 0 = Disables continuous reception Unimplemented: Read as '0' FERR: Framing Error bit 1 = Framing error (Updated by reading RCREG) 0 = No framing error OERR: Overrun Error bit 1 = Overrun (Cleared by clearing CREN) 0 = No overrun error RX9D: 9th bit of receive data (can be the software calculated parity bit)
bit 6:
bit 5:
bit 4:
bit 3: bit 2:
bit 1:
bit 0:
DS30412C-page 84
(c) 1996 Microchip Technology Inc.
PIC17C4X
FIGURE 13-3: USART TRANSMIT
Sync Master/Slave BRG Sync/Async CK/TX TSR Start 0 1 * * * 7 8 Stop DT 8 Clock / 16 Sync/Async /4 Sync/Async
Load Bit Count TXEN/ Write to TXREG Interrupt TXSTA<0> TXIE
TXREG
0 1 *** 7
Data Bus
FIGURE 13-4: USART RECEIVE
/4 Master/Slave Sync Sync/Async Async/Sync RCIE enable Bit Count START Detect Majority Detect Clock Data RSR MSb LSb Stop 8 7 * * * 1 0 FIFO Logic RCREG FERR FERR RX9D RX9D 7 *** 1 0 7 *** 1 0 Clk FIFO SREN/ CREN/ Start_Bit Interrupt
OSC
BRG
CK
Buffer Logic SPEN Buffer Logic
/ 16
RX
Async/Sync
RX9
Data Bus
(c) 1996 Microchip Technology Inc.
DS30412C-page 85
PIC17C4X
13.1 USART Baud Rate Generator (BRG)
Example 13-1 shows the calculation of the baud rate error for the following conditions: FOSC = 16 MHz Desired Baud Rate = 9600 SYNC = 0 The BRG supports both the Asynchronous and Synchronous modes of the USART. It is a dedicated 8-bit baud rate generator. The SPBRG register controls the period of a free running 8-bit timer. Table 13-1 shows the formula for computation of the baud rate for different USART modes. These only apply when the USART is in synchronous master mode (internal clock) and asynchronous mode. Given the desired baud rate and Fosc, the nearest integer value between 0 and 255 can be calculated using the formula below. The error in baud rate can then be determined.
EXAMPLE 13-1: CALCULATING BAUD RATE ERROR
Desired Baud rate=Fosc / (64 (X + 1)) 9600 = X = 16000000 /(64 (X + 1)) 25.042 = 25
Calculated Baud Rate=16000000 / (64 (25 + 1)) = 9615 (Calculated Baud Rate - Desired Baud Rate) Desired Baud Rate (9615 - 9600) / 9600 0.16%
TABLE 13-1:
SYNC
BAUD RATE FORMULA
Mode Baud Rate FOSC/(64(X+1)) FOSC/(4(X+1))
Error = = =
0 Asynchronous Synchronous 1 X = value in SPBRG (0 to 255)
Writing a new value to the SPBRG, causes the BRG timer to be reset (or cleared), this ensures that the BRG does not wait for a timer overflow before outputting the new baud rate.
TABLE 13-2:
Address Name
REGISTERS ASSOCIATED WITH BAUD RATE GENERATOR
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 -00x 0000 --1x xxxx xxxx Value on all other resets (Note1) 0000 -00u 0000 --1u uuuu uuuu
13h, Bank 0 15h, Bank 0 17h, Bank 0
RCSTA TXSTA SPBRG
SPEN CSRC
RX9 TX9
SREN TXEN
CREN SYNC
-- --
FERR --
OERR TRMT
RX9D TX9D
Baud rate generator register
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', shaded cells are not used by the Baud Rate Generator. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset.
DS30412C-page 86
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 13-3:
BAUD RATE (K) 0.3 1.2 2.4 9.6 19.2 76.8 96 300 500 HIGH LOW
BAUD RATES FOR SYNCHRONOUS MODE
SPBRG value (decimal) -- -- -- -- -- 106 85 27 16 0 255
FOSC = 33 MHz
KBAUD NA NA NA NA NA 77.10 95.93 294.64 485.29 8250 32.22 %ERROR -- -- -- -- -- +0.39 -0.07 -1.79 -2.94 -- --
FOSC = 25 MHz
KBAUD NA NA NA NA NA 77.16 96.15 297.62 480.77 6250 24.41 %ERROR -- -- -- -- -- +0.47 +0.16 -0.79 -3.85 -- --
SPBRG value (decimal) -- -- -- -- -- 80 64 20 12 0 255
FOSC = 20 MHz
KBAUD NA NA NA NA 19.53 76.92 96.15 294.1 500 5000 19.53 %ERROR -- -- -- -- +1.73 +0.16 +0.16 -1.96 0 -- --
SPBRG value (decimal) -- -- -- -- 255 64 51 16 9 0 255
FOSC = 16 MHz
KBAUD NA NA NA NA 19.23 76.92 95.24 307.69 500 4000 15.625 %ERROR -- -- -- -- +0.16 +0.16 -0.79 +2.56 0 -- --
SPBRG value (decimal) -- -- -- -- 207 51 41 12 7 0 255
BAUD RATE (K) 0.3 1.2 2.4 9.6 19.2 76.8 96 300 500 HIGH LOW BAUD RATE (K) 0.3 1.2 2.4 9.6 19.2 76.8 96 300 500 HIGH LOW
FOSC = 10 MHz
KBAUD NA NA NA 9.766 19.23 75.76 96.15 312.5 500 2500 9.766 FOSC = 3.579 MHz KBAUD NA NA NA 9.622 19.04 74.57 99.43 298.3 NA 894.9 3.496 %ERROR -- -- -- +0.23 -0.83 -2.90 _3.57 -0.57 -- -- -- %ERROR -- -- -- +1.73 +0.16 -1.36 +0.16 +4.17 0 -- --
SPBRG value (decimal) -- -- -- 255 129 32 25 7 4 0 255 SPBRG value (decimal) -- -- -- 92 46 11 8 2 -- 0 255
FOSC = 7.159 MHz
KBAUD NA NA NA 9.622 19.24 77.82 94.20 298.3 NA 1789.8 6.991 %ERROR -- -- -- +0.23 +0.23 +1.32 -1.88 -0.57 -- -- --
SPBRG value (decimal) -- -- -- 185 92 22 18 5 -- 0 255 SPBRG value (decimal) -- 207 103 25 12 2 -- -- -- 0 255
FOSC = 5.068 MHz
KBAUD NA NA NA 9.6 19.2 79.2 97.48 316.8 NA 1267 4.950 %ERROR -- -- -- 0 0 +3.13 +1.54 +5.60 -- -- --
SPBRG value (decimal) -- -- -- 131 65 15 12 3 -- 0 255 SPBRG value (decimal) 26 6 -- -- -- -- -- -- -- 0 255
FOSC = 1 MHz
KBAUD NA 1.202 2.404 9.615 19.24 83.34 NA NA NA 250 0.976 %ERROR -- +0.16 +0.16 +0.16 +0.16 +8.51 -- -- -- -- --
FOSC = 32.768 kHz
KBAUD 0.303 1.170 NA NA NA NA NA NA NA 8.192 0.032 %ERROR +1.14 -2.48 -- -- -- -- -- -- -- -- --
(c) 1996 Microchip Technology Inc.
DS30412C-page 87
PIC17C4X
TABLE 13-4:
BAUD RATE (K) 0.3 1.2 2.4 9.6 19.2 76.8 96 300 500 HIGH LOW
BAUD RATES FOR ASYNCHRONOUS MODE
SPBRG value (decimal) -- -- 214 53 26 6 4 1 0 0 255
FOSC = 33 MHz
KBAUD NA NA 2.398 9.548 19.09 73.66 103.12 257.81 515.62 515.62 2.014 %ERROR -- -- -0.07 -0.54 -0.54 -4.09 +7.42 -14.06 +3.13 -- --
FOSC = 25 MHz
KBAUD NA NA 2.396 9.53 19.53 78.13 97.65 390.63 NA -- 1.53 %ERROR -- -- 0.14 -0.76 +1.73 +1.73 +1.73 +30.21 -- -- --
SPBRG value (decimal) -- -- 162 40 19 4 3 0 -- 0 255
FOSC = 20 MHz
KBAUD NA 1.221 2.404 9.469 19.53 78.13 104.2 312.5 NA 312.5 1.221 %ERROR -- +1.73 +0.16 -1.36 +1.73 +1.73 +8.51 +4.17 -- -- --
SPBRG value (decimal) -- 255 129 32 15 3 2 0 -- 0 255
FOSC = 16 MHz
KBAUD NA 1.202 2.404 9.615 19.23 83.33 NA NA NA 250 0.977 %ERROR -- +0.16 +0.16 +0.16 +0.16 +8.51 -- -- -- -- --
SPBRG value (decimal) -- 207 103 25 12 2 -- -- -- 0 255
BAUD RATE (K) 0.3 1.2 2.4 9.6 19.2 76.8 96 300 500 HIGH LOW BAUD RATE (K) 0.3 1.2 2.4 9.6 19.2 76.8 96 300 500 HIGH LOW
FOSC = 10 MHz KBAUD NA 1.202 2.404 9.766 19.53 78.13 NA NA NA 156.3 0.610 FOSC = 3.579 MHz KBAUD 0.301 1.190 2.432 9.322 18.64 NA NA NA NA 55.93 0.218 %ERROR +0.23 -0.83 +1.32 -2.90 -2.90 -- -- -- -- -- -- %ERROR -- +0.16 +0.16 +1.73 +1.73 +1.73 -- -- -- -- --
SPBRG value (decimal) -- 129 64 15 7 1 -- -- -- 0 255 SPBRG value (decimal) 185 46 22 5 2 -- -- -- -- 0 255
FOSC = 7.159 MHz
KBAUD NA 1.203 2.380 9.322 18.64 NA NA NA NA 111.9 0.437 %ERROR -- _0.23 -0.83 -2.90 -2.90 -- -- -- -- -- --
SPBRG value (decimal) -- 92 46 11 5 -- -- -- -- 0 255 SPBRG value (decimal) 51 12 6 -- -- -- -- -- -- 0 255
FOSC = 5.068 MHz
KBAUD 0.31 1.2 2.4 9.9 19.8 79.2 NA NA NA 79.2 0.309 %ERROR +3.13 0 0 -3.13 +3.13 +3.13 -- -- -- -- --
SPBRG value (decimal) 255 65 32 7 3 0 -- -- -- 0 255 SPBRG value (decimal) 1 -- -- -- -- -- -- -- -- 0 255
FOSC = 1 MHz
KBAUD 0.300 1.202 2.232 NA NA NA NA NA NA 15.63 0.061 %ERROR +0.16 +0.16 -6.99 -- -- -- -- -- -- -- --
FOSC = 32.768 kHz
KBAUD 0.256 NA NA NA NA NA NA NA NA 0.512 0.002 %ERROR -14.67 -- -- -- -- -- -- -- -- -- --
DS30412C-page 88
(c) 1996 Microchip Technology Inc.
PIC17C4X
13.2 USART Asynchronous Mode
In this mode, the USART uses standard nonreturn-to-zero (NRZ) format (one start bit, eight or nine data bits, and one stop bit). The most common data format is 8-bits. An on-chip dedicated 8-bit baud rate generator can be used to derive standard baud rate frequencies from the oscillator. The USART's transmitter and receiver are functionally independent but use the same data format and baud rate. The baud rate generator produces a clock x64 of the bit shift rate. Parity is not supported by the hardware, but can be implemented in software (and stored as the ninth data bit). Asynchronous mode is stopped during SLEEP. The asynchronous mode is selected by clearing the SYNC bit (TXSTA<4>). The USART Asynchronous module consists of the following important elements: * * * * Baud Rate Generator Sampling Circuit Asynchronous Transmitter Asynchronous Receiver USART ASYNCHRONOUS TRANSMITTER Transmission is enabled by setting the TXEN (TXSTA<5>) bit. The actual transmission will not occur until TXREG has been loaded with data and the baud rate generator (BRG) has produced a shift clock (Figure 13-5). The transmission can also be started by first loading TXREG and then setting TXEN. Normally when transmission is first started, the TSR is empty, so a transfer to TXREG will result in an immediate transfer to TSR resulting in an empty TXREG. A back-to-back transfer is thus possible (Figure 13-6). Clearing TXEN during a transmission will cause the transmission to be aborted. This will reset the transmitter and the RA5/TX/CK pin will revert to hi-impedance. In order to select 9-bit transmission, the TX9 (TXSTA<6>) bit should be set and the ninth bit should be written to TX9D (TXSTA<0>). The ninth bit must be written before writing the 8-bit data to the TXREG. This is because a data write to TXREG can result in an immediate transfer of the data to the TSR (if the TSR is empty). Steps to follow when setting up an Asynchronous Transmission: 1. 2. 3. 4. 5. 6. 7. Initialize the SPBRG register for the appropriate baud rate. Enable the asynchronous serial port by clearing the SYNC bit and setting the SPEN bit. If interrupts are desired, then set the TXIE bit. If 9-bit transmission is desired, then set the TX9 bit. Load data to the TXREG register. If 9-bit transmission is selected, the ninth bit should be loaded in TX9D. Enable the transmission by setting TXEN (starts transmission).
13.2.1
The USART transmitter block diagram is shown in Figure 13-3. The heart of the transmitter is the transmit shift register (TSR). The shift register obtains its data from the read/write transmit buffer (TXREG). TXREG is loaded with data in software. The TSR is not loaded until the stop bit has been transmitted from the previous load. As soon as the stop bit is transmitted, the TSR is loaded with new data from the TXREG (if available). Once TXREG transfers the data to the TSR (occurs in one TCY at the end of the current BRG cycle), the TXREG is empty and an interrupt bit, TXIF (PIR<1>) is set. This interrupt can be enabled or disabled by the TXIE bit (PIE<1>). TXIF will be set regardless of TXIE and cannot be reset in software. It will reset only when new data is loaded into TXREG. While TXIF indicates the status of the TXREG, the TRMT (TXSTA<1>) bit shows the status of the TSR. TRMT is a read only bit which is set when the TSR is empty. No interrupt logic is tied to this bit, so the user has to poll this bit in order to determine if the TSR is empty. Note: The TSR is not mapped in data memory, so it is not available to the user.
Writing the transmit data to the TXREG, then enabling the transmit (setting TXEN) allows transmission to start sooner then doing these two events in the opposite order. Note: To terminate a transmission, either clear the SPEN bit, or the TXEN bit. This will reset the transmit logic, so that it will be in the proper state when transmit is re-enabled.
(c) 1996 Microchip Technology Inc.
DS30412C-page 89
PIC17C4X
FIGURE 13-5: ASYNCHRONOUS MASTER TRANSMISSION
Write to TXREG BRG output (shift clock) TX (RA5/TX/CK pin) Word 1
Start Bit
Bit 0
Bit 1 Word 1
Bit 7/8
Stop Bit
TXIF bit
Word 1 Transmit Shift Reg TRMT bit
FIGURE 13-6: ASYNCHRONOUS MASTER TRANSMISSION (BACK TO BACK)
Write to TXREG BRG output (shift clock) TX (RA5/TX/CK pin) TXIF bit Word 1 Word 2
Start Bit
Bit 0
Bit 1 Word 1
Bit 7/8
Stop Bit
Start Bit Word 2
Bit 0
Word 1 Transmit Shift Reg. TRMT bit Note: This timing diagram shows two consecutive transmissions.
Word 2 Transmit Shift Reg.
TABLE 13-5:
Address Name
REGISTERS ASSOCIATED WITH ASYNCHRONOUS TRANSMISSION
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 0010 0000 -00x xxxx xxxx CA2IE -- CA1IE -- TXIE TRMT RCIE TX9D 0000 0000 0000 --1x xxxx xxxx Value on all other resets (Note1) 0000 0010 0000 -00u uuuu uuuu 0000 0000 0000 --1u uuuu uuuu
16h, Bank 1 13h, Bank 0 16h, Bank 0 17h, Bank 1 15h, Bank 0 17h, Bank 0
PIR RCSTA TXREG PIE TXSTA SPBRG
RBIF SPEN
TMR3IF TMR2IF TMR1IF RX9 SREN CREN
CA2IF --
CA1IF FERR
TXIF OERR
RCIF RX9D
Serial port transmit register RBIE CSRC TMR3IE TMR2IE TMR1IE TX9 TXEN SYNC
Baud rate generator register
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', shaded cells are not used for asynchronous transmission. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset.
DS30412C-page 90
(c) 1996 Microchip Technology Inc.
PIC17C4X
13.2.2 USART ASYNCHRONOUS RECEIVER Note: The receiver block diagram is shown in Figure 13-4. The data comes in the RA4/RX/DT pin and drives the data recovery block. The data recovery block is actually a high speed shifter operating at 16 times the baud rate, whereas the main receive serial shifter operates at the bit rate or at FOSC. Once asynchronous mode is selected, reception is enabled by setting bit CREN (RCSTA<4>). The heart of the receiver is the receive (serial) shift register (RSR). After sampling the stop bit, the received data in the RSR is transferred to the RCREG (if it is empty). If the transfer is complete, the interrupt bit RCIF (PIR<0>) is set. The actual interrupt can be enabled/disabled by setting/clearing the RCIE (PIE<0>) bit. RCIF is a read only bit which is cleared by the hardware. It is cleared when RCREG has been read and is empty. RCREG is a double buffered register; (i.e. it is a two deep FIFO). It is possible for two bytes of data to be received and transferred to the RCREG FIFO and a third byte begin shifting to the RSR. On detection of the stop bit of the third byte, if the RCREG is still full, then the overrun error bit, OERR (RCSTA<1>) will be set. The word in the RSR will be lost. RCREG can be read twice to retrieve the two bytes in the FIFO. The OERR bit has to be cleared in software which is done by resetting the receive logic (CREN is set). If the OERR bit is set, transfers from the RSR to RCREG are inhibited, so it is essential to clear the OERR bit if it is set. The framing error bit FERR (RCSTA<2>) is set if a stop bit is not detected. The FERR and the 9th receive bit are buffered the same way as the receive data. Reading the RCREG register will allow the RX9D and FERR bits to be loaded with values for the next received Received data; therefore, it is essential for the user to read the RCSTA register before reading RCREG in order not to lose the old FERR and RX9D information. SAMPLING
13.2.3
The data on the RA4/RX/DT pin is sampled three times by a majority detect circuit to determine if a high or a low level is present at the RA4/RX/DT pin. The sampling is done on the seventh, eighth and ninth falling edges of a x16 clock (Figure 11-3). The x16 clock is a free running clock, and the three sample points occur at a frequency of every 16 falling edges.
FIGURE 13-7: RX PIN SAMPLING SCHEME
RX (RA4/RX/DT pin) baud CLK x16 CLK 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 Start bit Baud CLK for all but start bit Bit0
Samples
(c) 1996 Microchip Technology Inc.
DS30412C-page 91
PIC17C4X
Steps to follow when setting up an Asynchronous Reception: 1. 2. 3. 4. 5. 6. Initialize the SPBRG register for the appropriate baud rate. Enable the asynchronous serial port by clearing the SYNC bit and setting the SPEN bit. If interrupts are desired, then set the RCIE bit. If 9-bit reception is desired, then set the RX9 bit. Enable the reception by setting the CREN bit. The RCIF bit will be set when reception completes and an interrupt will be generated if the RCIE bit was set. 7. Read RCSTA to get the ninth bit (if enabled) and FERR bit to determine if any error occurred during reception. Read RCREG for the 8-bit received data. If an overrun error occurred, clear the error by clearing the OERR bit. Note: To terminate a reception, either clear the SREN and CREN bits, or the SPEN bit. This will reset the receive logic, so that it will be in the proper state when receive is re-enabled.
8. 9.
FIGURE 13-8: ASYNCHRONOUS RECEPTION
RX (RA4/RX/DT pin) Rcv shift reg Rcv buffer reg Read Rcv buffer reg RCREG RCIF (interrupt flag) OERR bit CREN Word 1 RCREG Word 2 RCREG Start bit bit0 bit1 bit7/8 Stop bit Start bit bit0 bit7/8 Stop bit Start bit bit7/8 Stop bit
Word 3
Note: This timing diagram shows three words appearing on the RX input. The RCREG (receive buffer) is read after the third word, causing the OERR (overrun) bit to be set.
TABLE 13-6:
Address Name
REGISTERS ASSOCIATED WITH ASYNCHRONOUS RECEPTION
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 0010 0000 -00x xxxx xxxx 0000 0000 0000 --1x xxxx xxxx Value on all other resets (Note1) 0000 0010 0000 -00u uuuu uuuu 0000 0000 0000 --1u uuuu uuuu
16h, Bank 1 13h, Bank 0 14h, Bank 0 17h, Bank 1 15h, Bank 0 17h, Bank 0
PIR RCSTA RCREG PIE TXSTA SPBRG
RBIF SPEN RX7 RBIE CSRC
TMR3IF TMR2IF TMR1IF RX9 RX6 SREN RX5 CREN RX4
CA2IF -- RX3 CA2IE --
CA1IF FERR RX2 CA1IE --
TXIF OERR RX1 TXIE TRMT
RCIF RX9D RX0 RCIE TX9D
TMR3IE TMR2IE TMR1IE TX9 TXEN SYNC
Baud rate generator register
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', shaded cells are not used for asynchronous reception. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset.
DS30412C-page 92
(c) 1996 Microchip Technology Inc.
PIC17C4X
13.3 USART Synchronous Master Mode
In Master Synchronous mode, the data is transmitted in a half-duplex manner; i.e. transmission and reception do not occur at the same time: when transmitting data, the reception is inhibited and vice versa. The synchronous mode is entered by setting the SYNC (TXSTA<4>) bit. In addition, the SPEN (RCSTA<7>) bit is set in order to configure the RA5 and RA4 I/O ports to CK (clock) and DT (data) lines respectively. The Master mode indicates that the processor transmits the master clock on the CK line. The Master mode is entered by setting the CSRC (TXSTA<7>) bit. 13.3.1 USART SYNCHRONOUS MASTER TRANSMISSION RA4/RX/DT pin reverts to a hi-impedance state (for a reception). The RA5/TX/CK pin will remain an output if the CSRC bit is set (internal clock). The transmitter logic is not reset, although it is disconnected from the pins. In order to reset the transmitter, the user has to clear the TXEN bit. If the SREN bit is set (to interrupt an ongoing transmission and receive a single word), then after the single word is received, SREN will be cleared and the serial port will revert back to transmitting, since the TXEN bit is still set. The DT line will immediately switch from hi-impedance receive mode to transmit and start driving. To avoid this, TXEN should be cleared. In order to select 9-bit transmission, the TX9 (TXSTA<6>) bit should be set and the ninth bit should be written to TX9D (TXSTA<0>). The ninth bit must be written before writing the 8-bit data to TXREG. This is because a data write to TXREG can result in an immediate transfer of the data to the TSR (if the TSR is empty). If the TSR was empty and TXREG was written before writing the "new" TX9D, the "present" value of TX9D is loaded. Steps to follow when setting up a Synchronous Master Transmission: 1. Initialize the SPBRG register for the appropriate baud rate (see Baud Rate Generator Section for details). Enable the synchronous master serial port by setting the SYNC, SPEN, and CSRC bits. Ensure that the CREN and SREN bits are clear (these bits override transmission when set). If interrupts are desired, then set the TXIE bit (the GLINTD bit must be clear and the PEIE bit must be set). If 9-bit transmission is desired, then set the TX9 bit. Start transmission by loading data to the TXREG register. If 9-bit transmission is selected, the ninth bit should be loaded in TX9D. Enable the transmission by setting TXEN.
The USART transmitter block diagram is shown in Figure 13-3. The heart of the transmitter is the transmit (serial) shift register (TSR). The shift register obtains its data from the read/write transmit buffer TXREG. TXREG is loaded with data in software. The TSR is not loaded until the last bit has been transmitted from the previous load. As soon as the last bit is transmitted, the TSR is loaded with new data from TXREG (if available). Once TXREG transfers the data to the TSR (occurs in one TCY at the end of the current BRG cycle), TXREG is empty and the TXIF (PIR<1>) bit is set. This interrupt can be enabled/disabled by setting/clearing the TXIE bit (PIE<1>). TXIF will be set regardless of the state of bit TXIE and cannot be cleared in software. It will reset only when new data is loaded into TXREG. While TXIF indicates the status of TXREG, TRMT (TXSTA<1>) shows the status of the TSR. TRMT is a read only bit which is set when the TSR is empty. No interrupt logic is tied to this bit, so the user has to poll this bit in order to determine if the TSR is empty. The TSR is not mapped in data memory, so it is not available to the user. Transmission is enabled by setting the TXEN (TXSTA<5>) bit. The actual transmission will not occur until TXREG has been loaded with data. The first data bit will be shifted out on the next available rising edge of the clock on the RA5/TX/CK pin. Data out is stable around the falling edge of the synchronous clock (Figure 13-10). The transmission can also be started by first loading TXREG and then setting TXEN. This is advantageous when slow baud rates are selected, since BRG is kept in RESET when the TXEN, CREN, and SREN bits are clear. Setting the TXEN bit will start the BRG, creating a shift clock immediately. Normally when transmission is first started, the TSR is empty, so a transfer to TXREG will result in an immediate transfer to the TSR, resulting in an empty TXREG. Back-to-back transfers are possible. Clearing TXEN during a transmission will cause the transmission to be aborted and will reset the transmitter. The RA4/RX/DT and RA5/TX/CK pins will revert to hi-impedance. If either CREN or SREN are set during a transmission, the transmission is aborted and the
2. 3. 4.
5. 6. 7. 8.
Writing the transmit data to the TXREG, then enabling the transmit (setting TXEN) allows transmission to start sooner then doing these two events in the reverse order. Note: To terminate a transmission, either clear the SPEN bit, or the TXEN bit. This will reset the transmit logic, so that it will be in the proper state when transmit is re-enabled.
(c) 1996 Microchip Technology Inc.
DS30412C-page 93
PIC17C4X
TABLE 13-7:
Address Name
REGISTERS ASSOCIATED WITH SYNCHRONOUS MASTER TRANSMISSION
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 0010 0000 -00x xxxx xxxx 0000 0000 0000 --1x xxxx xxxx Value on all other resets (Note1) 0000 0010 0000 -00u uuuu uuuu 0000 0000 0000 --1u uuuu uuuu
16h, Bank 1 13h, Bank 0 16h, Bank 0 17h, Bank 1 15h, Bank 0 17h, Bank 0
PIR RCSTA TXREG PIE TXSTA SPBRG
RBIF SPEN TX7 RBIE CSRC
TMR3IF TMR2IF TMR1IF RX9 TX6 SREN TX5 CREN TX4
CA2IF -- TX3 CA2IE --
CA1IF FERR TX2 CA1IE --
TXIF OERR TX1 TXIE TRMT
RCIF RX9D TX0 RCIE TX9D
TMR3IE TMR2IE TMR1IE TX9 TXEN SYNC
Baud rate generator register
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', shaded cells are not used for synchronous master transmission. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset.
FIGURE 13-9: SYNCHRONOUS TRANSMISSION
Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4 Q3 Q4 Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4Q1 Q2Q3 Q4
DT (RA4/RX/DT pin) CK (RA5/TX/CK pin) Write to TXREG Write word 1 TXIF Interrupt flag TRMT
bit0
bit1 Word 1
bit2
bit7
bit0 Word 2
Write word 2
TXEN
'1'
Note: Sync master mode; BRG = 0. Continuous transmission of two 8-bit words.
FIGURE 13-10: SYNCHRONOUS TRANSMISSION (THROUGH TXEN)
DT (RA4/RX/DT pin) CK (RA5/TX/CK pin) Write to TXREG bit0 bit1 bit2 bit6 bit7
TXIF bit
TRMT bit
DS30412C-page 94
(c) 1996 Microchip Technology Inc.
PIC17C4X
13.3.2 USART SYNCHRONOUS MASTER RECEPTION Steps to follow when setting up a Synchronous Master Reception: 1. 2. 3. 4. 5. 6. Initialize the SPBRG register for the appropriate baud rate. See Section 13.1 for details. Enable the synchronous master serial port by setting bits SYNC, SPEN, and CSRC. If interrupts are desired, then set the RCIE bit. If 9-bit reception is desired, then set the RX9 bit. If a single reception is required, set bit SREN. For continuous reception set bit CREN. The RCIF bit will be set when reception is complete and an interrupt will be generated if the RCIE bit was set. Read RCSTA to get the ninth bit (if enabled) and determine if any error occurred during reception. Read the 8-bit received data by reading RCREG. If any error occurred, clear the error by clearing CREN.
Once synchronous mode is selected, reception is enabled by setting either the SREN (RCSTA<5>) bit or the CREN (RCSTA<4>) bit. Data is sampled on the RA4/RX/DT pin on the falling edge of the clock. If SREN is set, then only a single word is received. If CREN is set, the reception is continuous until CREN is reset. If both bits are set, then CREN takes precedence. After clocking the last bit, the received data in the Receive Shift Register (RSR) is transferred to RCREG (if it is empty). If the transfer is complete, the interrupt bit RCIF (PIR<0>) is set. The actual interrupt can be enabled/disabled by setting/clearing the RCIE (PIE<0>) bit. RCIF is a read only bit which is RESET by the hardware. In this case it is reset when RCREG has been read and is empty. RCREG is a double buffered register; i.e., it is a two deep FIFO. It is possible for two bytes of data to be received and transferred to the RCREG FIFO and a third byte to begin shifting into the RSR. On the clocking of the last bit of the third byte, if RCREG is still full, then the overrun error bit OERR (RCSTA<1>) is set. The word in the RSR will be lost. RCREG can be read twice to retrieve the two bytes in the FIFO. The OERR bit has to be cleared in software. This is done by clearing the CREN bit. If OERR bit is set, transfers from RSR to RCREG are inhibited, so it is essential to clear OERR bit if it is set. The 9th receive bit is buffered the same way as the receive data. Reading the RCREG register will allow the RX9D and FERR bits to be loaded with values for the next received data; therefore, it is essential for the user to read the RCSTA register before reading RCREG in order not to lose the old FERR and RX9D information.
7. 8. 9.
Note:
To terminate a reception, either clear the SREN and CREN bits, or the SPEN bit. This will reset the receive logic, so that it will be in the proper state when receive is re-enabled.
FIGURE 13-11: SYNCHRONOUS RECEPTION (MASTER MODE, SREN)
Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
DT (RA4/RX/DT pin) CK (RA5/TX/CK pin) Write to the SREN bit SREN bit CREN bit RCIF bit Read RCREG '0'
bit0
bit1
bit2
bit3
bit4
bit5
bit6
bit7
'0'
Note: Timing diagram demonstrates SYNC master mode with SREN = 1.
(c) 1996 Microchip Technology Inc.
DS30412C-page 95
PIC17C4X
TABLE 13-8:
Address Name
REGISTERS ASSOCIATED WITH SYNCHRONOUS MASTER RECEPTION
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 0010 0000 -00x xxxx xxxx 0000 0000 0000 --1x xxxx xxxx Value on all other resets (Note1) 0000 0010 0000 -00u uuuu uuuu 0000 0000 0000 --1u uuuu uuuu
16h, Bank 1 13h, Bank 0 14h, Bank 0 17h, Bank 1 15h, Bank 0 17h, Bank 0
PIR RCSTA RCREG PIE TXSTA SPBRG
RBIF SPEN RX7 RBIE CSRC
TMR3IF TMR2IF TMR1IF RX9 RX6 SREN RX5 CREN RX4
CA2IF -- RX3 CA2IE --
CA1IF FERR RX2 CA1IE --
TXIF OERR RX1 TXIE TRMT
RCIF RX9D RX0 RCIE TX9D
TMR3IE TMR2IE TMR1IE TX9 TXEN SYNC
Baud rate generator register
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', shaded cells are not used for synchronous master reception. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset.
DS30412C-page 96
(c) 1996 Microchip Technology Inc.
PIC17C4X
13.4 USART Synchronous Slave Mode
13.4.2 USART SYNCHRONOUS SLAVE RECEPTION The synchronous slave mode differs from the master mode in the fact that the shift clock is supplied externally at the RA5/TX/CK pin (instead of being supplied internally in the master mode). This allows the device to transfer or receive data in the SLEEP mode. The slave mode is entered by clearing the CSRC (TXSTA<7>) bit. 13.4.1 USART SYNCHRONOUS SLAVE TRANSMIT
Operation of the synchronous master and slave modes are identical except in the case of the SLEEP mode. Also, SREN is a don't care in slave mode. If receive is enabled (CREN) prior to the SLEEP instruction, then a word may be received during SLEEP. On completely receiving the word, the RSR will transfer the data to RCREG (setting RCIF) and if the RCIE bit is set, the interrupt generated will wake the chip from SLEEP. If the global interrupt is enabled, the program will branch to the interrupt vector (0020h). Steps to follow when setting up a Synchronous Slave Reception: 1. Enable the synchronous master serial port by setting the SYNC and SPEN bits and clearing the CSRC bit. If interrupts are desired, then set the RCIE bit. If 9-bit reception is desired, then set the RX9 bit. To enable reception, set the CREN bit. The RCIF bit will be set when reception is complete and an interrupt will be generated if the RCIE bit was set. Read RCSTA to get the ninth bit (if enabled) and determine if any error occurred during reception. Read the 8-bit received data by reading RCREG. If any error occurred, clear the error by clearing the CREN bit.
The operation of the sync master and slave modes are identical except in the case of the SLEEP mode. If two words are written to TXREG and then the SLEEP instruction executes, the following will occur. The first word will immediately transfer to the TSR and will transmit as the shift clock is supplied. The second word will remain in TXREG. TXIF will not be set. When the first word has been shifted out of TSR, TXREG will transfer the second word to the TSR and the TXIF flag will now be set. If TXIE is enabled, the interrupt will wake the chip from SLEEP and if the global interrupt is enabled, then the program will branch to interrupt vector (0020h). Steps to follow when setting up a Synchronous Slave Transmission: 1. Enable the synchronous slave serial port by setting the SYNC and SPEN bits and clearing the CSRC bit. Clear the CREN bit. If interrupts are desired, then set the TXIE bit. If 9-bit transmission is desired, then set the TX9 bit. Start transmission by loading data to TXREG. If 9-bit transmission is selected, the ninth bit should be loaded in TX9D. Enable the transmission by setting TXEN.
2. 3. 4. 5.
6. 7. 8.
2. 3. 4. 5. 6. 7.
Note:
To abort reception, either clear the SPEN bit, the SREN bit (when in single receive mode), or the CREN bit (when in continuous receive mode). This will reset the receive logic, so that it will be in the proper state when receive is re-enabled.
Writing the transmit data to the TXREG, then enabling the transmit (setting TXEN) allows transmission to start sooner then doing these two events in the reverse order. Note: To terminate a transmission, either clear the SPEN bit, or the TXEN bit. This will reset the transmit logic, so that it will be in the proper state when transmit is re-enabled.
(c) 1996 Microchip Technology Inc.
DS30412C-page 97
PIC17C4X
TABLE 13-9:
Address Name
REGISTERS ASSOCIATED WITH SYNCHRONOUS SLAVE TRANSMISSION
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 0010 0000 -00x xxxx xxxx 0000 0000 0000 --1x xxxx xxxx Value on all other resets (Note1) 0000 0010 0000 -00u uuuu uuuu 0000 0000 0000 --1u uuuu uuuu
16h, Bank 1 13h, Bank 0 16h, Bank 0 17h, Bank 1 15h, Bank 0 17h, Bank 0
PIR RCSTA TXREG PIE TXSTA SPBRG
RBIF SPEN TX7 RBIE CSRC
TMR3IF TMR2IF TMR1IF RX9 TX6 SREN TX5 CREN TX4
CA2IF -- TX3 CA2IE --
CA1IF FERR TX2 CA1IE --
TXIF OERR TX1 TXIE TRMT
RCIF RX9D TX0 RCIE TX9D
TMR3IE TMR2IE TMR1IE TX9 TXEN SYNC
Baud rate generator register
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', shaded cells are not used for synchronous slave transmission. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset.
TABLE 13-10: REGISTERS ASSOCIATED WITH SYNCHRONOUS SLAVE RECEPTION
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset 0000 0010 0000 -00x xxxx xxxx 0000 0000 0000 --1x xxxx xxxx Value on all other resets (Note1) 0000 0010 0000 -00u uuuu uuuu 0000 0000 0000 --1u uuuu uuuu
16h, Bank1 13h, Bank0 14h, Bank0 17h, Bank1 15h, Bank 0 17h, Bank0
PIR RCSTA RCREG PIE TXSTA SPBRG
RBIF SPEN RX7 RBIE CSRC
TMR3IF TMR2IF TMR1IF RX9 RX6 SREN RX5 CREN RX4
CA2IF -- RX3 CA2IE --
CA1IF FERR RX2 CA1IE --
TXIF OERR RX1 TXIE TRMT
RCIF RX9D RX0 RCIE TX9D
TMR3IE TMR2IE TMR1IE TX9 TXEN SYNC
Baud rate generator register
Legend: x = unknown, u = unchanged, - = unimplemented read as a '0', shaded cells are not used for synchronous slave reception. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset.
DS30412C-page 98
(c) 1996 Microchip Technology Inc.
PIC17C4X
14.0 SPECIAL FEATURES OF THE CPU
The PIC17CXX has a Watchdog Timer which can be shut off only through EPROM bits. It runs off its own RC oscillator for added reliability. There are two timers that offer necessary delays on power-up. One is the Oscillator Start-up Timer (OST), intended to keep the chip in RESET until the crystal oscillator is stable. The other is the Power-up Timer (PWRT), which provides a fixed delay of 96 ms (nominal) on power-up only, designed to keep the part in RESET while the power supply stabilizes. With these two timers on-chip, most applications need no external reset circuitry. The SLEEP mode is designed to offer a very low current power-down mode. The user can wake from SLEEP through external reset, Watchdog Timer Reset or through an interrupt. Several oscillator options are also made available to allow the part to fit the application. The RC oscillator option saves system cost while the LF crystal option saves power. Configuration bits are used to select various options. This configuration word has the format shown in Figure 14-1.
What sets a microcontroller apart from other processors are special circuits to deal with the needs of real time applications. The PIC17CXX family has a host of such features intended to maximize system reliability, minimize cost through elimination of external components, provide power saving operating modes and offer code protection. These are: * OSC selection * Reset - Power-on Reset (POR) - Power-up Timer (PWRT) - Oscillator Start-up Timer (OST) * Interrupts * Watchdog Timer (WDT) * SLEEP * Code protection
FIGURE 14-1: CONFIGURATION WORD
R/P - 1 PM2 (1) bit15-7 U-x -- bit15-7 U-x -- U-x -- U-x -- U-x -- U-x -- U-x -- U-x -- bit0 R/P - 1 FOSC0 bit0
R/P - 1 PM1
U-x --
R/P - 1 R/P - 1 R/P - 1 R/P - 1 PM0 WDTPS1 WDTPS0 FOSC1
R = Readable bit P = Programmable bit U = Unimplemented - n = Value for Erased Device (x = unknown)
bit 15-9: Unimplemented: Read as a '1' bit 15,6,4:PM2, PM1, PM0, Processor Mode Select bits 111 = Microprocessor Mode 110 = Microcontroller mode 101 = Extended microcontroller mode 000 = Code protected microcontroller mode bit 7, 5: Unimplemented: Read as a '0' bit 3-2: WDTPS1:WDTPS0, WDT Postscaler Select bits 11 = WDT enabled, postscaler = 1 10 = WDT enabled, postscaler = 256 01 = WDT enabled, postscaler = 64 00 = WDT disabled, 16-bit overflow timer bit 1-0: FOSC1:FOSC0, Oscillator Select bits 11 = EC oscillator 10 = XT oscillator 01 = RC oscillator 00 = LF oscillator Note 1: This bit does not exist on the PIC17C42. Reading this bit will return an unknown value (x).
(c) 1996 Microchip Technology Inc.
DS30412C-page 99
This document was created with FrameMaker 4 0 4
PIC17C4X
14.1 Configuration Bits 14.2
14.2.1
Oscillator Configurations
OSCILLATOR TYPES
The PIC17CXX has up to seven configuration locations (Table 14-1). These locations can be programmed (read as '0') or left unprogrammed (read as '1') to select various device configurations. Any write to a configuration location, regardless of the data, will program that configuration bit. A TABLWT instruction is required to write to program memory locations. The configuration bits can be read by using the TABLRD instructions. Reading any configuration location between FE00h and FE07h will read the low byte of the configuration word (Figure 14-1) into the TABLATL register. The TABLATH register will be FFh. Reading a configuration location between FE08h and FE0Fh will read the high byte of the configuration word into the TABLATL register. The TABLATH register will be FFh. Addresses FE00h thorough FE0Fh are only in the program memory space for microcontroller and code protected microcontroller modes. A device programmer will be able to read the configuration word in any processor mode. See programming specifications for more detail.
The PIC17CXX can be operated in four different oscillator modes. The user can program two configuration bits (FOSC1:FOSC0) to select one of these four modes: * * * * LF: XT: EC: RC: Low Power Crystal Crystal/Resonator External Clock Input Resistor/Capacitor CRYSTAL OSCILLATOR / CERAMIC RESONATORS
14.2.2
In XT or LF modes, a crystal or ceramic resonator is connected to the OSC1/CLKIN and OSC2/CLKOUT pins to establish oscillation (Figure 14-2). The PIC17CXX Oscillator design requires the use of a parallel cut crystal. Use of a series cut crystal may give a frequency out of the crystal manufacturers specifications. For frequencies above 20 MHz, it is common for the crystal to be an overtone mode crystal. Use of overtone mode crystals require a tank circuit to attenuate the gain at the fundamental frequency. Figure 14-3 shows an example of this.
TABLE 14-1:
Bit
CONFIGURATION LOCATIONS
Address
FOSC0 FE00h FOSC1 FE01h WDTPS0 FE02h WDTPS1 FE03h PM0 FE04h PM1 FE06h (1) PM2 FE0Fh (1) Note 1: This location does not exist on the PIC17C42.
FIGURE 14-2: CRYSTAL OR CERAMIC RESONATOR OPERATION (XT OR LF OSC CONFIGURATION)
OSC1 C1 XTAL OSC2 Note1 C2 To internal logic PIC17CXX RF SLEEP
Note:
When programming the desired configuration locations, they must be programmed in ascending order. Starting with address FE00h.
See Table 14-2 and Table 14-3 for recommended values of C1 and C2.
Note 1: A series resistor may be required for AT strip cut crystals.
DS30412C-page 100
(c) 1996 Microchip Technology Inc.
PIC17C4X
FIGURE 14-3: CRYSTAL OPERATION, OVERTONE CRYSTALS (XT OSC CONFIGURATION)
C1 OSC1
TABLE 14-3:
Osc Type LF
CAPACITOR SELECTION FOR CRYSTAL OSCILLATOR
C1 C2
Freq
SLEEP C2 OSC2
0.1 F
PIC17C42
To filter the fundamental frequency 1= (2f)2 LC2 Where f = tank circuit resonant frequency. This should be midway between the fundamental and the 3rd overtone frequencies of the crystal.
TABLE 14-2:
CAPACITOR SELECTION FOR CERAMIC RESONATORS
Resonator Frequency Capacitor Range C1 = C2
Oscillator Type LF
455 kHz 15 - 68 pF 2.0 MHz 10 - 33 pF XT 4.0 MHz 22 - 68 pF 8.0 MHz 33 - 100 pF 16.0 MHz 33 - 100 pF Higher capacitance increases the stability of the oscillator but also increases the start-up time. These values are for design guidance only. Since each resonator has its own characteristics, the user should consult the resonator manufacturer for appropriate values of external components. Resonators Used: 455 kHz 2.0 MHz 4.0 MHz 8.0 MHz 16.0 MHz Panasonic EFO-A455K04B Murata Erie CSA2.00MG Murata Erie CSA4.00MG Murata Erie CSA8.00MT Murata Erie CSA16.00MX 0.3% 0.5% 0.5% 0.5% 0.5%
32 kHz(1) 100-150 pF 100-150 pF 1 MHz 10-33 pF 10-33 pF 2 MHz 10-33 pF 10-33 pF XT 2 MHz 47-100 pF 47-100 pF 4 MHz 15-68 pF 15-68 pF 8 MHz (2) 15-47 pF 15-47 pF TBD TBD 16 MHz 15-47 pF 15-47 pF 25 MHz 0 (3) 0 (3) 32 MHz (3) Higher capacitance increases the stability of the oscillator but also increases the start-up time and the oscillator current. These values are for design guidance only. RS may be required in XT mode to avoid overdriving the crystals with low drive level specification. Since each crystal has its own characteristics, the user should consult the crystal manufacturer for appropriate values for external components. Note 1: For VDD > 4.5V, C1 = C2 30 pF is recommended. 2: RS of 330 is required for a capacitor combination of 15/15 pF.
3: Only the capacitance of the board was present.
Crystals Used: 32.768 kHz 1.0 MHz 2.0 MHz 4.0 MHz 8.0 MHz 16.0 MHz 25 MHz 32 MHz 14.2.3 Epson C-001R32.768K-A ECS-10-13-1 ECS-20-20-1 ECS-40-20-1 ECS ECS-80-S-4 ECS-80-18-1 ECS-160-20-1 CTS CTS25M CRYSTEK HF-2 20 PPM 50 PPM 50 PPM 50 PPM 50 PPM TBD 50 PPM 50 PPM
EXTERNAL CLOCK OSCILLATOR
Resonators used did not have built-in capacitors.
In the EC oscillator mode, the OSC1 input can be driven by CMOS drivers. In this mode, the OSC1/CLKIN pin is hi-impedance and the OSC2/CLKOUT pin is the CLKOUT output (4 TOSC).
FIGURE 14-4: EXTERNAL CLOCK INPUT OPERATION (EC OSC CONFIGURATION)
Clock from ext. system CLKOUT (FOSC/4) OSC1 PIC17CXX OSC2
(c) 1996 Microchip Technology Inc.
DS30412C-page 101
PIC17C4X
14.2.4 EXTERNAL CRYSTAL OSCILLATOR CIRCUIT 14.2.5 RC OSCILLATOR For timing insensitive applications, the RC device option offers additional cost savings. RC oscillator frequency is a function of the supply voltage, the resistor (Rext) and capacitor (Cext) values, and the operating temperature. In addition to this, oscillator frequency will vary from unit to unit due to normal process parameter variation. Furthermore, the difference in lead frame capacitance between package types will also affect oscillation frequency, especially for low Cext values. The user also needs to take into account variation due to tolerance of external R and C components used. Figure 14-6 shows how the R/C combination is connected to the PIC17CXX. For Rext values below 2.2 k, the oscillator operation may become unstable, or stop completely. For very high Rext values (e.g. 1 M), the oscillator becomes sensitive to noise, humidity and leakage. Thus, we recommend to keep Rext between 3 k and 100 k. Although the oscillator will operate with no external capacitor (Cext = 0 pF), we recommend using values above 20 pF for noise and stability reasons. With little or no external capacitance, oscillation frequency can vary dramatically due to changes in external capacitances, such as PCB trace capacitance or package lead frame capacitance. See Section 18.0 for RC frequency variation from part to part due to normal process variation. The variation is larger for larger R (since leakage current variation will affect RC frequency more for large R) and for smaller C (since variation of input capacitance will affect RC frequency more). See Section 18.0 for variation of oscillator frequency due to VDD for given Rext/Cext values as well as frequency variation due to operating temperature for given R, C, and VDD values. The oscillator frequency, divided by 4, is available on the OSC2/CLKOUT pin, and can be used for test purposes or to synchronize other logic (see Figure 3-2 for waveform).
Either a prepackaged oscillator can be used or a simple oscillator circuit with TTL gates can be built. Prepackaged oscillators provide a wide operating range and better stability. A well-designed crystal oscillator will provide good performance with TTL gates. Two types of crystal oscillator circuits can be used: one with series resonance, or one with parallel resonance. Figure 14-5 shows implementation of a parallel resonant oscillator circuit. The circuit is designed to use the fundamental frequency of the crystal. The 74AS04 inverter performs the 180-degree phase shift that a parallel oscillator requires. The 4.7 k resistor provides the negative feedback for stability. The 10 k potentiometer biases the 74AS04 in the linear region. This could be used for external oscillator designs.
FIGURE 14-5: EXTERNAL PARALLEL RESONANT CRYSTAL OSCILLATOR CIRCUIT
+5V To Other Devices 10k 4.7k 74AS04 74AS04 PIC17CXX OSC1
10k XTAL 10k 20 pF 20 pF
Figure 14-6 shows a series resonant oscillator circuit. This circuit is also designed to use the fundamental frequency of the crystal. The inverter performs a 180-degree phase shift in a series resonant oscillator circuit. The 330 k resistors provide the negative feedback to bias the inverters in their linear region.
FIGURE 14-7: RC OSCILLATOR MODE
VDD Rext OSC1 Internal clock PIC17CXX OSC2/CLKOUT Fosc/4
FIGURE 14-6: EXTERNAL SERIES RESONANT CRYSTAL OSCILLATOR CIRCUIT
To Other Devices 74AS04
330 k 74AS04 0.1 F XTAL
330 k 74AS04
Cext
PIC17CXX OSC1
VSS
DS30412C-page 102
(c) 1996 Microchip Technology Inc.
PIC17C4X
14.3 Watchdog Timer (WDT)
14.3.2 CLEARING THE WDT AND POSTSCALER The Watchdog Timer's function is to recover from software malfunction. The WDT uses an internal free running on-chip RC oscillator for its clock source. This does not require any external components. This RC oscillator is separate from the RC oscillator of the OSC1/CLKIN pin. That means that the WDT will run, even if the clock on the OSC1/CLKIN and OSC2/CLKOUT pins of the device has been stopped, for example, by execution of a SLEEP instruction. During normal operation and SLEEP mode, a WDT time-out generates a device RESET. The WDT can be permanently disabled by programming the configuration bits WDTPS1:WDTPS0 as '00' (Section 14.1). Under normal operation, the WDT must be cleared on a regular interval. This time is less the minimum WDT overflow time. Not clearing the WDT in this time frame will cause the WDT to overflow and reset the device. 14.3.1 WDT PERIOD The WDT and postscaler are cleared when: * * * * The device is in the reset state A SLEEP instruction is executed A CLRWDT instruction is executed Wake-up from SLEEP by an interrupt
The WDT counter/postscaler will start counting on the first edge after the device exits the reset state. 14.3.3 WDT PROGRAMMING CONSIDERATIONS
It should also be taken in account that under worst case conditions (VDD = Min., Temperature = Max., max. WDT postscaler) it may take several seconds before a WDT time-out occurs. The WDT and postscaler is the Power-up Timer during the Power-on Reset sequence. 14.3.4 WDT AS NORMAL TIMER
The WDT has a nominal time-out period of 12 ms, (with postscaler = 1). The time-out periods vary with temperature, VDD and process variations from part to part (see DC specs). If longer time-out periods are desired, a postscaler with a division ratio of up to 1:256 can be assigned to the WDT. Thus, typical time-out periods up to 3.0 seconds can be realized. The CLRWDT and SLEEP instructions clear the WDT and the postscaler (if assigned to the WDT) and prevent it from timing out thus generating a device RESET condition. The TO bit in the CPUSTA register will be cleared upon a WDT time-out.
When the WDT is selected as a normal timer, the clock source is the device clock. Neither the WDT nor the postscaler are directly readable or writable. The overflow time is 65536 TOSC cycles. On overflow, the TO bit is cleared (device is not reset). The CLRWDT instruction can be used to set the TO bit. This allows the WDT to be a simple overflow timer. When in sleep, the WDT does not increment.
(c) 1996 Microchip Technology Inc.
DS30412C-page 103
PIC17C4X
FIGURE 14-8: WATCHDOG TIMER BLOCK DIAGRAM
On-chip RC Oscillator(1)
WDT
Postscaler
4 - to - 1 MUX WDT Enable Note 1: This oscillator is separate from the external RC oscillator on the OSC1 pin.
WDTPS1:WDTPS0
WDT Overflow
TABLE 14-4:
Address
REGISTERS/BITS ASSOCIATED WITH THE WATCHDOG TIMER
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value on Power-on Reset (Note 2) --11 11-Value on all other resets (Note1) (Note 2) --11 qq--
Name
-- 06h, Unbanked
Config CPUSTA
-- --
PM1 --
-- STKAV
PM0 GLINTD
WDTPS1 WDTPS0 TO PD
FOSC1 --
FOSC0 --
Legend: - = unimplemented read as '0', q - value depends on condition, shaded cells are not used by the WDT. Note 1: Other (non power-up) resets include: external reset through MCLR and Watchdog Timer Reset. 2: This value will be as the device was programmed, or if unprogrammed, will read as all '1's.
DS30412C-page 104
(c) 1996 Microchip Technology Inc.
PIC17C4X
14.4 Power-down Mode (SLEEP)
The Power-down mode is entered by executing a SLEEP instruction. This clears the Watchdog Timer and postscaler (if enabled). The PD bit is cleared and the TO bit is set (in the CPUSTA register). In SLEEP mode, the oscillator driver is turned off. The I/O ports maintain their status (driving high, low, or hi-impedance). The MCLR/VPP pin must be at a logic high level (VIHMC). A WDT time-out RESET does not drive the MCLR/VPP pin low. 14.4.1 WAKE-UP FROM SLEEP PD bit, which is set on power-up, is cleared when SLEEP is invoked. The TO bit is cleared if WDT time-out occurred (and caused wake-up). When the SLEEP instruction is being executed, the next instruction (PC + 1) is pre-fetched. For the device to wake-up through an interrupt event, the corresponding interrupt enable bit must be set (enabled). Wake-up is regardless of the state of the GLINTD bit. If the GLINTD bit is set (disabled), the device continues execution at the instruction after the SLEEP instruction. If the GLINTD bit is clear (enabled), the device executes the instruction after the SLEEP instruction and then branches to the interrupt vector address. In cases where the execution of the instruction following SLEEP is not desirable, the user should have a NOP after the SLEEP instruction. Note: If the global interrupts are disabled (GLINTD is set), but any interrupt source has both its interrupt enable bit and the corresponding interrupt flag bits set, the device will immediately wake-up from sleep. The TO bit is set, and the PD bit is cleared.
The device can wake up from SLEEP through one of the following events: * * * * A POR reset External reset input on MCLR/VPP pin WDT Reset (if WDT was enabled) Interrupt from RA0/INT pin, RB port change, T0CKI interrupt, or some Peripheral Interrupts
The following peripheral interrupts can wake-up from SLEEP: * * * * Capture1 interrupt Capture2 interrupt USART synchronous slave transmit interrupt USART synchronous slave receive interrupt
The WDT is cleared when the device wake from SLEEP, regardless of the source of wake-up. 14.4.1.1 WAKE-UP DELAY
Other peripherals can not generate interrupts since during SLEEP, no on-chip Q clocks are present. Any reset event will cause a device reset. Any interrupt event is considered a continuation of program execution. The TO and PD bits in the CPUSTA register can be used to determine the cause of device reset. The
When the oscillator type is configured in XT or LF mode, the Oscillator Start-up Timer (OST) is activated on wake-up. The OST will keep the device in reset for 1024TOSC. This needs to be taken into account when considering the interrupt response time when coming out of SLEEP.
FIGURE 14-9: WAKE-UP FROM SLEEP THROUGH INTERRUPT
Q1 OSC1 Tost(2) CLKOUT(4) INT (RA0/INT pin) INTF flag GLINTD bit INSTRUCTION FLOW PC Instruction fetched Instruction executed PC Inst (PC) = SLEEP Inst (PC-1) PC+1 Inst (PC+1) SLEEP Processor in SLEEP PC+2 0004h Inst (PC+2) Inst (PC+1) Dummy Cycle 0005h Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Interrupt Latency (2)
Note 1: XT or LF oscillator mode assumed. 2: Tost = 1024Tosc (drawing not to scale). This delay will not be there for RC osc mode. 3: When GLINTD = 0 processor jumps to interrupt routine after wake-up. If GLINTD = 1, execution will continue in line. 4: CLKOUT is not available in these osc modes, but shown here for timing reference.
(c) 1996 Microchip Technology Inc.
DS30412C-page 105
PIC17C4X
14.4.2 MINIMIZING CURRENT CONSUMPTION
14.5
Code Protection
To minimize current consumption, all I/O pins should be either at VDD, or VSS, with no external circuitry drawing current from the I/O pin. I/O pins that are hi-impedance inputs should be pulled high or low externally to avoid switching currents caused by floating inputs. The T0CKI input should be at VDD or VSS. The contributions from on-chip pull-ups on PORTB should also be considered, and disabled when possible.
The code in the program memory can be protected by selecting the microcontroller in code protected mode (PM2:PM0 = '000'). Note: PM2 does not exist on the PIC17C42. To select code protected microcontroller mode, PM1:PM0 = '00'.
In this mode, instructions that are in the on-chip program memory space, can continue to read or write the program memory. An instruction that is executed outside of the internal program memory range will be inhibited from writing to or reading from program memory.
Note:
Microchip does not recommend code protecting windowed devices.
If the code protection bit(s) have not been programmed, the on-chip program memory can be read out for verification purposes.
DS30412C-page 106
(c) 1996 Microchip Technology Inc.
PIC17C4X
15.0 INSTRUCTION SET SUMMARY
TABLE 15-1:
Field
f p i t
The PIC17CXX instruction set consists of 58 instructions. Each instruction is a 16-bit word divided into an OPCODE and one or more operands. The opcode specifies the instruction type, while the operand(s) further specify the operation of the instruction. The PIC17CXX instruction set can be grouped into three types: * byte-oriented * bit-oriented * literal and control operations. These formats are shown in Figure 15-1. Table 15-1 shows the field descriptions for the opcodes. These descriptions are useful for understanding the opcodes in Table 15-2 and in each specific instruction descriptions. byte-oriented instructions, 'f' represents a file register designator and 'd' represents a destination designator. The file register designator specifies which file register is to be used by the instruction. The destination designator specifies where the result of the operation is to be placed. If 'd' = '0', the result is placed in the WREG register. If 'd' = '1', the result is placed in the file register specified by the instruction. bit-oriented instructions, 'b' represents a bit field designator which selects the number of the bit affected by the operation, while 'f' represents the number of the file in which the bit is located. literal and control operations, 'k' represents an 8- or 11-bit constant or literal value. The instruction set is highly orthogonal and is grouped into: * byte-oriented operations * bit-oriented operations * literal and control operations All instructions are executed within one single instruction cycle, unless: * a conditional test is true * the program counter is changed as a result of an instruction * a table read or a table write instruction is executed (in this case, the execution takes two instruction cycles with the second cycle executed as a NOP) One instruction cycle consists of four oscillator periods. Thus, for an oscillator frequency of 25 MHz, the normal instruction execution time is 160 ns. If a conditional test is true or the program counter is changed as a result of an instruction, the instruction execution time is 320 ns.
OPCODE FIELD DESCRIPTIONS
Description
Register file address (00h to FFh) Peripheral register file address (00h to 1Fh) Table pointer control i = '0' (do not change) i = '1' (increment after instruction execution) Table byte select t = '0' (perform operation on lower byte) t = '1' (perform operation on upper byte literal field, constant data) Bit address within an 8-bit file register Literal field, constant data or label Don't care location (= '0' or '1') The assembler will generate code with x = '0'. It is the recommended form of use for compatibility with all Microchip software tools. Destination select 0 = store result in WREG 1 = store result in file register f Default is d = '1' Unused, encoded as '0' Destination select 0 = store result in file register f and in the WREG 1 = store result in file register f Default is s = '1'
WREG Working register (accumulator) b k x
d
u s
label Label name C,DC, ALU status bits Carry, Digit Carry, Zero, Overflow Z,OV GLINTD Global Interrupt Disable bit (CPUSTA<4>) TBLPTR Table Pointer (16-bit) TBLAT Table Latch (16-bit) consists of high byte (TBLATH) and low byte (TBLATL) TBLATL Table Latch low byte TBLATH Table Latch high byte TOS PC BSR WDT TO PD Top of Stack Program Counter Bank Select Register Watchdog Timer Counter Time-out bit Power-down bit
dest Destination either the WREG register or the specified register file location [] Options Contents Assigned to Register bit field In the set of
() <>
italics User defined term (font is courier)
(c) 1996 Microchip Technology Inc.
DS30412C-page 107
This document was created with FrameMaker 4 0 4
PIC17C4X
Table 15-2 lists the instructions recognized by the MPASM assembler. Note 1: Any unused opcode is Reserved. Use of any reserved opcode may cause unexpected operation. Note 2: The shaded instructions are not available in the PIC17C42 All instruction examples use the following format to represent a hexadecimal number: 0xhh where h signifies a hexadecimal digit. To represent a binary number: 0000 0100b where b signifies a binary string.
15.1
Special Function Registers as Source/Destination
The PIC17C4X's orthogonal instruction set allows read and write of all file registers, including special function registers. There are some special situations the user should be aware of: 15.1.1 ALUSTA AS DESTINATION
If an instruction writes to ALUSTA, the Z, C, DC and OV bits may be set or cleared as a result of the instruction and overwrite the original data bits written. For example, executing CLRF ALUSTA will clear register ALUSTA, and then set the Z bit leaving 0000 0100b in the register. 15.1.2 PCL AS SOURCE OR DESTINATION
FIGURE 15-1: GENERAL FORMAT FOR INSTRUCTIONS
Byte-oriented file register operations 15 OPCODE 9 8 d 7 f (FILE #) 0
Read, write or read-modify-write on PCL may have the following results: Read PC: Write PCL: Read-Modify-Write: PCH PCLATH; PCL dest PCLATH PCH; 8-bit destination value PCL PCL ALU operand PCLATH PCH; 8-bit result PCL
d = 0 for destination WREG d = 1 for destination f f = 8-bit file register address Byte to Byte move operations 15 13 12 87 OPCODE p (FILE #) 0 f (FILE #)
Where PCH = program counter high byte (not an addressable register), PCLATH = Program counter high holding latch, dest = destination, WREG or f. 15.1.3 BIT MANIPULATION
p = peripheral register file address f = 8-bit file register address Bit-oriented file register operations 15 OPCODE 11 10 87 b (BIT #) 0 f (FILE #)
All bit manipulation instructions are done by first reading the entire register, operating on the selected bit and writing the result back (read-modify-write). The user should keep this in mind when operating on special function registers, such as ports.
b = 3-bit address f = 8-bit file register address Literal and control operations 15 OPCODE k = 8-bit immediate value Call and GOTO operations 15 13 12 OPCODE 0 k (literal) 8 7 k (literal) 0
k = 13-bit immediate value
DS30412C-page 108
(c) 1996 Microchip Technology Inc.
PIC17C4X
15.2 Q Cycle Activity
The 4 Q cycles that make up an instruction cycle (Tcy) can be generalized as: Q1: Instruction Decode Cycle or forced NOP Q2: Instruction Read Cycle or NOP Q3: Instruction Execute Q4: Instruction Write Cycle or NOP Each instruction will show the detailed Q cycle operation for the instruction. Each instruction cycle (Tcy) is comprised of four Q cycles (Q1-Q4). The Q cycles provide the timing/designation for the Decode, Read, Execute, Write etc., of each instruction cycle. The following diagram shows the relationship of the Q cycles to the instruction cycle.
FIGURE 15-2: Q CYCLE ACTIVITY
Q1 Tosc Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1 Q2 Q3 Q4
Tcy1
Tcy2
Tcy3
(c) 1996 Microchip Technology Inc.
DS30412C-page 109
PIC17C4X
TABLE 15-2: PIC17CXX INSTRUCTION SET
Mnemonic, Operands Description Cycles MSb 16-bit Opcode LSb Status Affected Notes
BYTE-ORIENTED FILE REGISTER OPERATIONS ADDWF ADDWFC ANDWF CLRF COMF CPFSEQ CPFSGT CPFSLT DAW DECF DECFSZ DCFSNZ INCF INCFSZ INFSNZ IORWF MOVFP MOVPF MOVWF MULWF NEGW NOP RLCF RLNCF RRCF RRNCF SETF SUBWF SUBWFB SWAPF TABLRD f,d f,d f,d f,s f,d f f f f,s f,d f,d f,d f,d f,d f,d f,d f,p p,f f f f,s -- f,d f,d f,d f,d f,s f,d f,d f,d t,i,f ADD WREG to f ADD WREG and Carry bit to f AND WREG with f Clear f, or Clear f and Clear WREG Complement f Compare f with WREG, skip if f = WREG Compare f with WREG, skip if f > WREG Compare f with WREG, skip if f < WREG Decimal Adjust WREG Register Decrement f Decrement f, skip if 0 Decrement f, skip if not 0 Increment f Increment f, skip if 0 Increment f, skip if not 0 Inclusive OR WREG with f Move f to p Move p to f Move WREG to f Multiply WREG with f Negate WREG No Operation Rotate left f through Carry Rotate left f (no carry) Rotate right f through Carry Rotate right f (no carry) Set f Subtract WREG from f Subtract WREG from f with Borrow Swap f Table Read 1 1 1 1 1 1 (2) 1 (2) 1 (2) 1 1 1 (2) 1 (2) 1 1 (2) 1 (2) 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 (3) 0000 111d ffff ffff 0001 000d ffff ffff 0000 101d ffff ffff 0010 100s ffff ffff 0001 001d ffff ffff 0011 0001 ffff ffff 0011 0010 ffff ffff 0011 0000 ffff ffff 0010 111s ffff ffff 0000 011d ffff ffff 0001 011d ffff ffff 0010 011d ffff ffff 0001 010d ffff ffff 0001 111d ffff ffff 0010 010d ffff ffff 0000 100d ffff ffff 011p pppp ffff ffff 010p pppp ffff ffff 0000 0001 ffff ffff 0011 0100 ffff ffff 0010 110s ffff ffff 0000 0000 0000 0000 0001 101d ffff ffff 0010 001d ffff ffff 0001 100d ffff ffff 0010 000d ffff ffff 0010 101s ffff ffff 0000 010d ffff ffff 0000 001d ffff ffff 0001 110d ffff ffff 1010 10ti ffff ffff OV,C,DC,Z OV,C,DC,Z Z None Z None None None C OV,C,DC,Z None None OV,C,DC,Z None None Z None Z None None OV,C,DC,Z None C None C None None OV,C,DC,Z OV,C,DC,Z None None 7 3 1 1 9 1,3 6,8 6,8 6,8 6,8 6,8 2,6,8 2,6,8 3 3
Legend: Note 1: 2: 3: 4: 5:
6: 7: 8: 9:
Refer to Table 15-1 for opcode field descriptions. 2's Complement method. Unsigned arithmetic. If s = '1', only the file is affected: If s = '0', both the WREG register and the file are affected; If only the Working register (WREG) is required to be affected, then f = WREG must be specified. During an LCALL, the contents of PCLATH are loaded into the MSB of the PC and kkkk kkkk is loaded into the LSB of the PC (PCL) Multiple cycle instruction for EPROM programming when table pointer selects internal EPROM. The instruction is terminated by an interrupt event. When writing to external program memory, it is a two-cycle instruction. Two-cycle instruction when condition is true, else single cycle instruction. Two-cycle instruction except for TABLRD to PCL (program counter low byte) in which case it takes 3 cycles. A "skip" means that instruction fetched during execution of current instruction is not executed, instead an NOP is executed. These instructions are not available on the PIC17C42.
DS30412C-page 110
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLE 15-2: PIC17CXX INSTRUCTION SET (Cont.'d)
Mnemonic, Operands TABLWT TLRD TLWT TSTFSZ XORWF t,i,f t,f t,f f f,d Description Cycles MSb Table Write Table Latch Read Table Latch Write Test f, skip if 0 Exclusive OR WREG with f 2 1 1 1 (2) 1 16-bit Opcode LSb Status Affected None None None None Z 6,8 Notes
1010 11ti ffff ffff 1010 00tx ffff ffff 1010 01tx ffff ffff 0011 0011 ffff ffff 0000 110d ffff ffff
5
BIT-ORIENTED FILE REGISTER OPERATIONS BCF BSF BTFSC BTFSS BTG f,b f,b f,b f,b f,b Bit Clear f Bit Set f Bit test, skip if clear Bit test, skip if set Bit Toggle f 1 1 1 (2) 1 (2) 1 1000 1bbb ffff ffff 1000 0bbb ffff ffff 1001 1bbb ffff ffff 1001 0bbb ffff ffff 0011 1bbb ffff ffff None None None None None 6,8 6,8
LITERAL AND CONTROL OPERATIONS ADDLW ANDLW CALL CLRWDT GOTO IORLW LCALL MOVLB MOVLR MOVLW MULLW RETFIE RETLW RETURN SLEEP SUBLW XORLW k k k -- k k k k k k k -- k -- -- k k ADD literal to WREG AND literal with WREG Subroutine Call Clear Watchdog Timer Unconditional Branch Inclusive OR literal with WREG Long Call Move literal to low nibble in BSR Move literal to high nibble in BSR Move literal to WREG Multiply literal with WREG Return from interrupt (and enable interrupts) Return literal to WREG Return from subroutine Enter SLEEP Mode Subtract WREG from literal Exclusive OR literal with WREG 1 1 2 1 2 1 2 1 1 1 1 2 2 2 1 1 1 1011 0001 kkkk kkkk 1011 0101 kkkk kkkk 111k kkkk kkkk kkkk 0000 0000 0000 0100 110k kkkk kkkk kkkk 1011 0011 kkkk kkkk 1011 0111 kkkk kkkk 1011 1000 uuuu kkkk 1011 101x kkkk uuuu 1011 0000 kkkk kkkk 1011 1100 kkkk kkkk 0000 0000 0000 0101 1011 0110 kkkk kkkk 0000 0000 0000 0010 0000 0000 0000 0011 1011 0010 kkkk kkkk 1011 0100 kkkk kkkk OV,C,DC,Z Z None TO,PD None Z None None None None None GLINTD None None TO, PD OV,C,DC,Z Z 9 7 7 7 9 4,7 7 7
Legend: Note 1: 2: 3: 4: 5:
6: 7: 8: 9:
Refer to Table 15-1 for opcode field descriptions. 2's Complement method. Unsigned arithmetic. If s = '1', only the file is affected: If s = '0', both the WREG register and the file are affected; If only the Working register (WREG) is required to be affected, then f = WREG must be specified. During an LCALL, the contents of PCLATH are loaded into the MSB of the PC and kkkk kkkk is loaded into the LSB of the PC (PCL) Multiple cycle instruction for EPROM programming when table pointer selects internal EPROM. The instruction is terminated by an interrupt event. When writing to external program memory, it is a two-cycle instruction. Two-cycle instruction when condition is true, else single cycle instruction. Two-cycle instruction except for TABLRD to PCL (program counter low byte) in which case it takes 3 cycles. A "skip" means that instruction fetched during execution of current instruction is not executed, instead an NOP is executed. These instructions are not available on the PIC17C42.
(c) 1996 Microchip Technology Inc.
DS30412C-page 111
PIC17C4X
ADDLW Syntax: Operands: Operation: Status Affected: Encoding: Description: ADD Literal to WREG [ label ] ADDLW 0 k 255 (WREG) + k (WREG) OV, C, DC, Z
1011 0001 kkkk kkkk The contents of WREG are added to the 8-bit literal 'k' and the result is placed in WREG.
ADDWF Syntax: Operands: Operation: Status Affected: Encoding: Description:
ADD WREG to f [ label ] ADDWF 0 f 255 d [0,1] (WREG) + (f) (dest) OV, C, DC, Z
0000 111d ffff ffff Add WREG to register 'f'. If 'd' is 0 the result is stored in WREG. If 'd' is 1 the result is stored back in register 'f'.
k
f,d
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'k' ADDLW
Words: Cycles: Q3
Execute
1 1 Q2
Read register 'f' ADDWF = = = = 0x17 0xC2 0xD9 0xC2
Q4
Write to WREG
Q Cycle Activity: Q1
Decode
Q3
Execute
Q4
Write to destination
Example:
0x15
Before Instruction
WREG = 0x10
Example:
WREG REG WREG REG
REG, 0
Before Instruction
After Instruction
WREG = 0x25
After Instruction
DS30412C-page 112
(c) 1996 Microchip Technology Inc.
PIC17C4X
ADDWFC Syntax: Operands: Operation: Status Affected: Encoding: Description: ADD WREG and Carry bit to f [ label ] ADDWFC 0 f 255 d [0,1] (WREG) + (f) + C (dest) OV, C, DC, Z
0001 000d ffff ffff Add WREG, the Carry Flag and data memory location 'f'. If 'd' is 0, the result is placed in WREG. If 'd' is 1, the result is placed in data memory location 'f'.
ANDLW Syntax: Operands: Operation: Status Affected: Encoding: Description:
And Literal with WREG [ label ] ANDLW 0 k 255 (WREG) .AND. (k) (WREG) Z
1011 0101 kkkk kkkk The contents of WREG are AND'ed with the 8-bit literal 'k'. The result is placed in WREG.
f,d
k
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'k' ANDLW = = 0xA3 0x03
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' ADDWFC 1 0x02 0x4D 0 0x02 0x50
Q3
Execute
Q4
Write to WREG
Q3
Execute
Q4
Write to destination
Example:
WREG WREG
0x5F
Example:
Carry bit = REG = WREG =
REG
0
Before Instruction After Instruction
Before Instruction
After Instruction
Carry bit = REG = WREG =
(c) 1996 Microchip Technology Inc.
DS30412C-page 113
PIC17C4X
ANDWF Syntax: Operands: Operation: Status Affected: Encoding: Description: AND WREG with f [ label ] ANDWF 0 f 255 d [0,1] (WREG) .AND. (f) (dest) Z
0000 101d ffff ffff The contents of WREG are AND'ed with register 'f'. If 'd' is 0 the result is stored in WREG. If 'd' is 1 the result is stored back in register 'f'.
BCF f,d Syntax: Operands: Operation: Status Affected: Encoding: Description: Words: Cycles: Q Cycle Activity: Q1
Decode
Bit Clear f [ label ] BCF 0 f 255 0b7 0 (f) None
1000 1bbb ffff ffff Bit 'b' in register 'f' is cleared.
f,b
1 1 Q2
Read register 'f' BCF
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' ANDWF = = = = 0x17 0xC2 0x17 0x02
Q3
Execute
Q4
Write register 'f' 7
Q3
Execute
Q4
Write to destination
Example:
FLAG_REG,
Before Instruction
FLAG_REG = 0xC7
Example:
WREG REG WREG REG
REG, 1
Before Instruction
After Instruction
FLAG_REG = 0x47
After Instruction
DS30412C-page 114
(c) 1996 Microchip Technology Inc.
PIC17C4X
BSF Syntax: Operands: Operation: Status Affected: Encoding: Description: Words: Cycles: Q Cycle Activity: Q1
Decode
Bit Set f [ label ] BSF 0 f 255 0b7 1 (f) None
1000 0bbb ffff ffff Bit 'b' in register 'f' is set.
BTFSC f,b Syntax: Operands: Operation: Status Affected: Encoding: Description:
Bit Test, skip if Clear [ label ] BTFSC f,b 0 f 255 0b7 skip if (f) = 0 None
1001 1bbb ffff ffff If bit 'b' in register 'f' is 0 then the next instruction is skipped. If bit 'b' is 0 then the next instruction fetched during the current instruction execution is discarded, and a NOP is executed instead, making this a two-cycle instruction.
1 1 Q2
Read register 'f' BSF
Q3
Execute
Q4
Write register 'f'
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1(2) Q2
Read register 'f'
Example:
FLAG_REG, 7
Before Instruction
FLAG_REG= 0x0A
Q3
Execute
Q4
NOP
After Instruction
FLAG_REG= 0x8A
If skip: Q1
Forced NOP
Q2
NOP HERE FALSE TRUE = = = = =
Q3
Execute BTFSC : : FLAG,1
Q4
NOP
Example:
Before Instruction
PC address (HERE) 0; address (TRUE) 1; address (FALSE)
After Instruction
If FLAG<1> PC If FLAG<1> PC
(c) 1996 Microchip Technology Inc.
DS30412C-page 115
PIC17C4X
BTFSS Syntax: Operands: Operation: Status Affected: Encoding: Description: Bit Test, skip if Set [ label ] BTFSS f,b 0 f 127 0b<7 skip if (f) = 1 None
1001 0bbb ffff ffff If bit 'b' in register 'f' is 1 then the next instruction is skipped. If bit 'b' is 1, then the next instruction fetched during the current instruction execution, is discarded and an NOP is executed instead, making this a two-cycle instruction.
BTG Syntax: Operands: Operation: Status Affected: Encoding: Description: Words: Cycles: Q Cycle Activity: Q1
Decode
Bit Toggle f [ label ] BTG f,b 0 f 255 0b<7 (f) (f) None
0011 1bbb ffff ffff Bit 'b' in data memory location 'f' is inverted.
1 1 Q2
Read register 'f' BTG = =
Q3
Execute
Q4
Write register 'f'
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1(2)
Example: Q2
Read register 'f'
PORTC,
4
Q3
Execute
Q4
NOP
Before Instruction:
PORTC PORTC 0111 0101 [0x75] 0110 0101 [0x65]
If skip: Q1
Forced NOP
After Instruction: Q3
Execute BTFSS : : FLAG,1
Q2
NOP HERE FALSE TRUE = = = = =
Q4
NOP
Example:
Before Instruction
PC address (HERE) 0; address (FALSE) 1; address (TRUE)
After Instruction
If FLAG<1> PC If FLAG<1> PC
DS30412C-page 116
(c) 1996 Microchip Technology Inc.
PIC17C4X
CALL Syntax: Operands: Operation: Subroutine Call [ label ] CALL k 0 k 4095 PC+ 1 TOS, k PC<12:0>, k<12:8> PCLATH<4:0>; PC<15:13> PCLATH<7:5> None
111k kkkk kkkk kkkk Subroutine call within 8K page. First, return address (PC+1) is pushed onto the stack. The 13-bit value is loaded into PC bits<12:0>. Then the upper-eight bits of the PC are copied into PCLATH. Call is a two-cycle instruction. See LCALL for calls outside 8K memory space.
CLRF Syntax: Operands: Operation: Status Affected: Encoding: Description:
Clear f [label] CLRF 0 f 255 00h f, s [0,1] 00h dest None
0010 100s ffff ffff Clears the contents of the specified register(s). s = 0: Data memory location 'f' and WREG are cleared. s = 1: Data memory location 'f' is cleared.
f,s
Status Affected: Encoding: Description:
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f'
Words: Cycles: Q Cycle Activity: Q1
Decode
1 2 Q2 Q3
Execute Execute CALL THERE
Q3
Execute
Q4
Write register 'f' and other specified register
Q4
NOP NOP
Read literal 'k'<7:0> Forced NOP NOP
Example:
CLRF = = 0x5A 0x00
FLAG_REG
Example:
PC = PC = TOS =
HERE
Before Instruction
FLAG_REG
Before Instruction
Address(HERE) Address(THERE) Address (HERE + 1)
After Instruction
FLAG_REG
After Instruction
(c) 1996 Microchip Technology Inc.
DS30412C-page 117
PIC17C4X
CLRWDT Syntax: Operands: Operation: Clear Watchdog Timer [ label ] CLRWDT None 00h WDT 0 WDT postscaler, 1 TO 1 PD TO, PD
0000 0000 0000 0100 CLRWDT instruction resets the watchdog timer. It also resets the prescaler of the WDT. Status bits TO and PD are set.
COMF Syntax: Operands: Operation: Status Affected: Encoding: Description:
Complement f [ label ] COMF 0 f 255 d [0,1] ( f ) (dest) Z
0001 001d ffff ffff The contents of register 'f' are complemented. If 'd' is 0 the result is stored in WREG. If 'd' is 1 the result is stored back in register 'f'.
f,d
Status Affected: Encoding: Description:
Words: Cycles: Q Cycle Activity: Q1
1 1 Q2
Read register 'f' COMF = = = 0x13 0x13 0xEC
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register ALUSTA CLRWDT = = = = = ? 0x00 0 1 1
Q3
Execute
Q4
Write register 'f'
Q3
Execute
Q4
NOP
Decode
Example:
REG1 REG1 WREG
REG1,0
Example:
Before Instruction After Instruction
Before Instruction
WDT counter
After Instruction
WDT counter WDT Postscaler
TO PD
DS30412C-page 118
(c) 1996 Microchip Technology Inc.
PIC17C4X
CPFSEQ Syntax: Operands: Operation: Compare f with WREG, skip if f = WREG [ label ] CPFSEQ 0 f 255
(f) - (WREG), skip if (f) = (WREG) (unsigned comparison)
CPFSGT Syntax: Operands: Operation:
Compare f with WREG, skip if f > WREG [ label ] CPFSGT 0 f 255
(f) - (WREG), skip if (f) > (WREG) (unsigned comparison)
f
f
Status Affected: Encoding: Description:
None
0011 0001 ffff ffff Compares the contents of data memory location 'f' to the contents of WREG by performing an unsigned subtraction. If 'f' = WREG then the fetched instruction is discarded and an NOP is executed instead making this a two-cycle instruction.
Status Affected: Encoding: Description:
None
0011 0010 ffff ffff Compares the contents of data memory location 'f' to the contents of the WREG by performing an unsigned subtraction. If the contents of 'f' > the contents of WREG then the fetched instruction is discarded and an NOP is executed instead making this a two-cycle instruction.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 (2) Q2
Read register 'f'
Words: Cycles: Q3
Execute
1 1 (2) Q2
Read register 'f'
Q4
NOP
Q Cycle Activity: Q1
Decode
Q3
Execute
Q4
NOP
If skip: Q1
Forced NOP
Q2
NOP HERE NEQUAL EQUAL = = = = = =
Q3
Execute CPFSEQ REG : : HERE ? ? WREG; Address (EQUAL) WREG; Address (NEQUAL)
Q4
NOP
If skip: Q1
Forced NOP
Q2
NOP HERE NGREATER GREATER = = > = =
Q3
Execute CPFSGT REG : :
Q4
NOP
Example:
Example:
Before Instruction
PC Address WREG REG
Before Instruction
PC WREG Address (HERE) ? WREG; Address (GREATER) WREG; Address (NGREATER)
After Instruction
If REG PC If REG PC
After Instruction
If REG PC If REG PC
(c) 1996 Microchip Technology Inc.
DS30412C-page 119
PIC17C4X
CPFSLT Syntax: Operands: Operation: Compare f with WREG, skip if f < WREG [ label ] CPFSLT 0 f 255
(f) - (WREG), skip if (f) < (WREG) (unsigned comparison)
DAW Syntax: Operands: Operation:
Decimal Adjust WREG Register [label] DAW 0 f 255 s [0,1]
If [WREG<3:0> >9] .OR. [DC = 1] then WREG<3:0> + 6 f<3:0>, s<3:0>; else WREG<3:0> f<3:0>, s<3:0>; If [WREG<7:4> >9] .OR. [C = 1] then WREG<7:4> + 6 f<7:4>, s<7:4> else WREG<7:4> f<7:4>, s<7:4>
f,s
f
Status Affected: Encoding: Description:
None
0011 0000 ffff ffff Compares the contents of data memory location 'f' to the contents of WREG by performing an unsigned subtraction. If the contents of 'f' < the contents of WREG, then the fetched instruction is discarded and an NOP is executed instead making this a two-cycle instruction.
Status Affected: Encoding: Description:
C
0010 111s ffff ffff DAW adjusts the eight bit value in WREG resulting from the earlier addition of two variables (each in packed BCD format) and produces a correct packed BCD result. s = 0: Result is placed in Data memory location 'f' and WREG. s = 1: Result is placed in Data memory location 'f'.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 (2) Q2
Read register 'f'
Q3
Execute
Q4
NOP
If skip: Q1
Forced NOP
Words: Q2
NOP HERE NLESS LESS = = < = =
1 1 Q2
Read register 'f'
Q3
Execute CPFSLT REG : : Address (HERE) ?
Q4
NOP
Cycles: Q Cycle Activity: Q1
Decode
Example:
Q3
Execute
Q4
Write register 'f' and other specified register
Before Instruction
PC W
After Instruction
If REG PC If REG PC WREG; Address (LESS) WREG; Address (NLESS)
Example1:
WREG REG1 C DC WREG REG1 C DC = = = = = = = =
DAW
REG1, 0
Before Instruction
0xA5 ?? 0 0 0x05 0x05 1 0
After Instruction
Example 2: Before Instruction
WREG REG1 C DC WREG REG1 C DC = = = = = = = = 0xCE ?? 0 0 0x24 0x24 1 0
After Instruction
DS30412C-page 120
(c) 1996 Microchip Technology Inc.
PIC17C4X
DECF Syntax: Operands: Operation: Status Affected: Encoding: Description: Decrement f [ label ] DECF f,d 0 f 255 d [0,1] (f) - 1 (dest) OV, C, DC, Z
0000 011d ffff ffff
DECFSZ Syntax: Operands: Operation: Status Affected: Encoding: Description:
Decrement f, skip if 0 [ label ] DECFSZ f,d 0 f 255 d [0,1] (f) - 1 (dest); skip if result = 0 None
0001 011d ffff ffff The contents of register 'f' are decremented. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'. If the result is 0, the next instruction, which is already fetched, is discarded, and an NOP is executed instead making it a two-cycle instruction.
Decrement register 'f'. If 'd' is 0 the result is stored in WREG. If 'd' is 1 the result is stored back in register 'f'.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' DECF = = = = 0x01 0 0x00 1
Q3
Execute
Q4
Write to destination
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1(2) Q2
Read register 'f' HERE CONTINUE
Example:
CNT Z CNT Z
CNT,
1
Before Instruction
Q3
Execute
Q4
Write to destination CNT, 1 LOOP
After Instruction Example:
DECFSZ GOTO
Before Instruction
PC CNT If CNT PC If CNT PC = = = = = Address (HERE) CNT - 1 0; Address (CONTINUE) 0; Address (HERE+1)
After Instruction
(c) 1996 Microchip Technology Inc.
DS30412C-page 121
PIC17C4X
DCFSNZ Syntax: Operands: Operation: Status Affected: Encoding: Description: Decrement f, skip if not 0 [label] DCFSNZ f,d 0 f 255 d [0,1] (f) - 1 (dest); skip if not 0 None
0010 011d ffff ffff The contents of register 'f' are decremented. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'. If the result is not 0, the next instruction, which is already fetched, is discarded, and an NOP is executed instead making it a two-cycle instruction.
GOTO Syntax: Operands: Operation:
Unconditional Branch [ label ] GOTO k 0 k 8191 k PC<12:0>; k<12:8> PCLATH<4:0>, PC<15:13> PCLATH<7:5> None
110k kkkk kkkk kkkk GOTO allows an unconditional branch anywhere within an 8K page boundary. The thirteen bit immediate value is loaded into PC bits <12:0>. Then the upper eight bits of PC are loaded into PCLATH. GOTO is always a two-cycle instruction.
Status Affected: Encoding: Description:
Words: Cycles: Q Cycle Activity: Q1
1 2 Q2 Q3
Execute Execute
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1(2) Q2
Read register 'f'
Q4
NOP NOP
Q3
Execute
Q4
Write to destination
Read literal 'k'<7:0> Forced NOP NOP
Decode
If skip: Q1
Forced NOP
Q2
NOP HERE ZERO NZERO = = = = =
Q3
Execute DCFSNZ : : ?
Q4
NOP
Example:
PC =
GOTO THERE Address (THERE)
After Instruction
Example:
TEMP, 1
Before Instruction
TEMP_VALUE
After Instruction
TEMP_VALUE If TEMP_VALUE PC If TEMP_VALUE PC TEMP_VALUE - 1, 0; Address (ZERO) 0; Address (NZERO)
DS30412C-page 122
(c) 1996 Microchip Technology Inc.
PIC17C4X
INCF Syntax: Operands: Operation: Status Affected: Encoding: Description: Increment f [ label ] INCF f,d 0 f 255 d [0,1] (f) + 1 (dest) OV, C, DC, Z
0001 010d ffff ffff
INCFSZ Syntax: Operands: Operation: Status Affected: Encoding: Description:
Increment f, skip if 0 [ label ] INCFSZ f,d 0 f 255 d [0,1] (f) + 1 (dest) skip if result = 0 None
0001 111d ffff ffff The contents of register 'f' are incremented. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'. If the result is 0, the next instruction, which is already fetched, is discarded, and an NOP is executed instead making it a two-cycle instruction.
The contents of register 'f' are incremented. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' INCF = = = = = = 0xFF 0 ? 0x00 1 1
Q3
Execute
Q4
Write to destination
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1(2) Q2
Read register 'f'
Example:
CNT Z C CNT Z C
CNT, 1
Before Instruction
Q3
Execute
Q4
Write to destination
If skip: Q1
Forced NOP
After Instruction
Q2
NOP HERE NZERO ZERO = = = = =
Q3
Execute INCFSZ : :
Q4
NOP CNT, 1
Example:
Before Instruction
PC CNT If CNT PC If CNT PC Address (HERE) CNT + 1 0; Address(ZERO) 0; Address(NZERO)
After Instruction
(c) 1996 Microchip Technology Inc.
DS30412C-page 123
PIC17C4X
INFSNZ Syntax: Operands: Operation: Status Affected: Encoding: Description: Increment f, skip if not 0 [label] INFSNZ f,d 0 f 255 d [0,1] (f) + 1 (dest), skip if not 0 None
0010 010d ffff ffff The contents of register 'f' are incremented. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'. If the result is not 0, the next instruction, which is already fetched, is discarded, and an NOP is executed instead making it a two-cycle instruction.
IORLW Syntax: Operands: Operation: Status Affected: Encoding: Description:
Inclusive OR Literal with WREG [ label ] IORLW k 0 k 255 (WREG) .OR. (k) (WREG) Z
1011 0011 kkkk kkkk The contents of WREG are OR'ed with the eight bit literal 'k'. The result is placed in WREG.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'k' IORLW = = 0x9A 0xBF
Q3
Execute
Q4
Write to WREG
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1(2) Q2
Read register 'f'
Example: Q3
Execute
0x35
Q4
Write to destination
Before Instruction
WREG WREG
After Instruction
If skip: Q1
Forced NOP
Q2
NOP HERE ZERO NZERO = = = = = = REG
Q3
Execute INFSNZ REG, 1
Q4
NOP
Example:
Before Instruction
REG REG If REG PC If REG PC
After Instruction
REG + 1 1; Address (ZERO) 0; Address (NZERO)
DS30412C-page 124
(c) 1996 Microchip Technology Inc.
PIC17C4X
IORWF Syntax: Operands: Operation: Status Affected: Encoding: Description: Inclusive OR WREG with f [ label ] IORWF f,d 0 f 255 d [0,1] (WREG) .OR. (f) (dest) Z
0000 100d ffff ffff Inclusive OR WREG with register 'f'. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'.
LCALL Syntax: Operands: Operation: Status Affected: Encoding: Description:
Long Call [ label ] LCALL k 0 k 255 PC + 1 TOS; k PCL, (PCLATH) PCH None
1011 0111 kkkk kkkk LCALL allows an unconditional subroutine call to anywhere within the 64k program memory space. First, the return address (PC + 1) is pushed onto the stack. A 16-bit destination address is then loaded into the program counter. The lower 8-bits of the destination address is embedded in the instruction. The upper 8-bits of PC is loaded from PC high holding latch, PCLATH.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' IORWF 0x13 0x91 0x13 0x93
Q3
Execute
Q4
Write to destination
Words: Cycles: Q Cycle Activity: Q1
Decode Forced NOP
1 2 Q2
Read literal 'k' NOP MOVLW MOVPF LCALL
Example:
RESULT = WREG =
RESULT, 0
Before Instruction
Q3
Execute Execute
Q4
Write register PCL NOP
After Instruction
RESULT = WREG =
Example:
HIGH(SUBROUTINE) WREG, PCLATH LOW(SUBROUTINE) 16-bit Address ? Address (SUBROUTINE)
Before Instruction
SUBROUTINE = PC =
After Instruction
PC =
(c) 1996 Microchip Technology Inc.
DS30412C-page 125
PIC17C4X
MOVFP Syntax: Operands: Operation: Status Affected: Encoding: Description: Move f to p [label] MOVFP f,p 0 f 255 0 p 31 (f) (p) None
011p pppp ffff ffff Move data from data memory location 'f' to data memory location 'p'. Location 'f' can be anywhere in the 256 word data space (00h to FFh) while 'p' can be 00h to 1Fh. Either 'p' or 'f' can be WREG (a useful special situation). MOVFP is particularly useful for transferring a data memory location to a peripheral register (such as the transmit buffer or an I/O port). Both 'f' and 'p' can be indirectly addressed.
MOVLB Syntax: Operands: Operation: Status Affected: Encoding: Description:
Move Literal to low nibble in BSR [ label ] MOVLB k 0 k 15 k (BSR<3:0>) None
1011 1000 uuuu kkkk The four bit literal 'k' is loaded in the Bank Select Register (BSR). Only the low 4-bits of the Bank Select Register are affected. The upper half of the BSR is unchanged. The assembler will encode the "u" fields as '0'.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'u:k'
Q3
Execute
Q4
Write literal 'k' to BSR<3:0>
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' MOVFP = = = =
Example: Q3
Execute
MOVLB = =
0x5 0x22 0x25
Before Instruction Q4
Write register 'p' BSR register
After Instruction
BSR register
Example:
REG1 REG2
REG1, REG2 0x33, 0x11 0x33, 0x33
Note:
Before Instruction
For the PIC17C42, only the low four bits of the BSR register are physically implemented. The upper nibble is read as '0'.
After Instruction
REG1 REG2
DS30412C-page 126
(c) 1996 Microchip Technology Inc.
PIC17C4X
MOVLR Syntax: Operands: Operation: Status Affected: Encoding: Description: Move Literal to high nibble in BSR [ label ] MOVLR k 0 k 15 k (BSR<7:4>) None
1011 101x kkkk uuuu The 4-bit literal 'k' is loaded into the most significant 4-bits of the Bank Select Register (BSR). Only the high 4-bits of the Bank Select Register are affected. The lower half of the BSR is unchanged. The assembler will encode the "u" fields as 0.
MOVLW Syntax: Operands: Operation: Status Affected: Encoding: Description: Words: Cycles: Q Cycle Activity: Q1
Decode
Move Literal to WREG [ label ] MOVLW k 0 k 255 k (WREG) None
1011 0000 kkkk kkkk The eight bit literal 'k' is loaded into WREG.
1 1 Q2
Read literal 'k' MOVLW = 0x5A
Q3
Execute
Q4
Write to WREG
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'k:u' MOVLR = = 5 0x22 0x52
Example: Q3
Execute
0x5A
Q4
Write literal 'k' to BSR<7:4>
After Instruction
WREG
Example:
Before Instruction
BSR register
After Instruction
BSR register
Note:
This instruction is not available in the PIC17C42 device.
(c) 1996 Microchip Technology Inc.
DS30412C-page 127
PIC17C4X
MOVPF Syntax: Operands: Operation: Status Affected: Encoding: Description: Move p to f [label] MOVPF p,f 0 f 255 0 p 31 (p) (f) Z
010p pppp ffff ffff Move data from data memory location 'p' to data memory location 'f'. Location 'f' can be anywhere in the 256 byte data space (00h to FFh) while 'p' can be 00h to 1Fh. Either 'p' or 'f' can be WREG (a useful special situation). MOVPF is particularly useful for transferring a peripheral register (e.g. the timer or an I/O port) to a data memory location. Both 'f' and 'p' can be indirectly addressed.
MOVWF Syntax: Operands: Operation: Status Affected: Encoding: Description:
Move WREG to f [ label ] MOVWF f 0 f 255 (WREG) (f) None
0000 0001 ffff ffff Move data from WREG to register 'f'. Location 'f' can be anywhere in the 256 word data space.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' MOVWF = = = = 0x4F 0xFF 0x4F 0x4F
Q3
Execute
Q4
Write register 'f'
Example:
WREG REG WREG REG
REG
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'p' MOVPF = = = =
Before Instruction
After Instruction Q3
Execute
Q4
Write register 'f'
Example:
REG1 REG2
REG1, REG2 0x11 0x33 0x11 0x11
Before Instruction
After Instruction
REG1 REG2
DS30412C-page 128
(c) 1996 Microchip Technology Inc.
PIC17C4X
MULLW Syntax: Operands: Operation: Status Affected: Encoding: Description: Multiply Literal with WREG [ label ] MULLW k 0 k 255 (k x WREG) PRODH:PRODL None
1011 1100 kkkk kkkk An unsigned multiplication is carried out between the contents of WREG and the 8-bit literal 'k'. The 16-bit result is placed in PRODH:PRODL register pair. PRODH contains the high byte. WREG is unchanged. None of the status flags are affected. Note that neither overflow nor carry is possible in this operation. A zero result is possible but not detected.
MULWF Syntax: Operands: Operation: Status Affected: Encoding: Description:
Multiply WREG with f [ label ] MULWF f 0 f 255 (WREG x f) PRODH:PRODL None
0011 0100 ffff ffff An unsigned multiplication is carried out between the contents of WREG and the register file location 'f'. The 16-bit result is stored in the PRODH:PRODL register pair. PRODH contains the high byte. Both WREG and 'f' are unchanged. None of the status flags are affected. Note that neither overflow nor carry is possible in this operation. A zero result is possible but not detected.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'k'
Words: Cycles: Q3
Execute
1 1 Q2
Read register 'f'
Q4
Write registers PRODH: PRODL
Q Cycle Activity: Q1
Decode
Q3
Execute
Q4
Write registers PRODH: PRODL
Example:
WREG PRODH PRODL
MULLW = = = = = =
0xC4 0xE2 ? ? 0xC4 0xAD 0x08
Example:
WREG REG PRODH PRODL
MULWF = = = = = = = =
REG 0xC4 0xB5 ? ? 0xC4 0xB5 0x8A 0x94
Before Instruction
Before Instruction
After Instruction
WREG PRODH PRODL
After Instruction
WREG REG PRODH PRODL
Note:
This instruction is not available in the PIC17C42 device. Note:
This instruction is not available in the PIC17C42 device.
(c) 1996 Microchip Technology Inc.
DS30412C-page 129
PIC17C4X
NEGW Syntax: Operands: Operation: Status Affected: Encoding: Description: Negate W [label] NEGW f,s 0 F 255 s [0,1] WREG + 1 (f); WREG + 1 s OV, C, DC, Z
0010 110s ffff ffff WREG is negated using two's complement. If 's' is 0 the result is placed in WREG and data memory location 'f'. If 's' is 1 the result is placed only in data memory location 'f'.
NOP Syntax: Operands: Operation: Status Affected: Encoding: Description: Words: Cycles: Q Cycle Activity: Q1
Decode
No Operation [ label ] None No operation None
0000 0000 0000 0000 No operation.
NOP
1 1 Q2
NOP
Q3
Execute
Q4
NOP
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f'
Example: Q3
Execute
Q4
Write register 'f' and other specified register
None.
Example:
WREG REG WREG REG = = = =
NEGW
REG,0
Before Instruction
0011 1010 [0x3A], 1010 1011 [0xAB] 1100 0111 [0xC6] 1100 0111 [0xC6]
After Instruction
DS30412C-page 130
(c) 1996 Microchip Technology Inc.
PIC17C4X
RETFIE Syntax: Operands: Operation: Return from Interrupt [ label ] None TOS (PC); 0 GLINTD; PCLATH is unchanged. GLINTD
0000 0000 0000 0101 Return from Interrupt. Stack is POP'ed and Top of Stack (TOS) is loaded in the PC. Interrupts are enabled by clearing the GLINTD bit. GLINTD is the global interrupt disable bit (CPUSTA<4>).
RETLW Syntax: Operands: Operation: Status Affected: Encoding: Description:
Return Literal to WREG [ label ] RETLW k 0 k 255 k (WREG); TOS (PC); PCLATH is unchanged None
1011 0110 kkkk kkkk WREG is loaded with the eight bit literal 'k'. The program counter is loaded from the top of the stack (the return address). The high address latch (PCLATH) remains unchanged.
RETFIE
Status Affected: Encoding: Description:
Words: Cycles: Q Cycle Activity: Q1
1 2 Q2
Read literal 'k' NOP
Words: Cycles: Q Cycle Activity: Q1
Decode
1 2 Q2
Read register T0STA NOP RETFIE TOS 0
Q3
Execute Execute
Q4
Write to WREG NOP
Q3
Execute
Q4
NOP
Decode Forced NOP
Forced NOP
Execute
NOP
Example:
Example: After Interrupt
PC = GLINTD =
CALL TABLE ; ; ; ; : TABLE ADDWF PC ; RETLW k0 ; RETLW k1 ; : : RETLW kn ;
WREG contains table offset value WREG now has table value WREG = offset Begin table
End of table
Before Instruction
WREG WREG = = 0x07 value of k7
After Instruction
(c) 1996 Microchip Technology Inc.
DS30412C-page 131
PIC17C4X
RETURN Syntax: Operands: Operation: Status Affected: Encoding: Description: Return from Subroutine [ label ] None TOS PC; None
0000 0000 0000 0010 Return from subroutine. The stack is popped and the top of the stack (TOS) is loaded into the program counter.
RLCF Syntax: Operands: Operation:
Rotate Left f through Carry [ label ] RLCF 0 f 255 d [0,1] f d; f<7> C; C d<0> C
0001 101d ffff ffff The contents of register 'f' are rotated one bit to the left through the Carry Flag. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is stored back in register 'f'.
RETURN
f,d
Status Affected: Encoding: Description:
Words: Cycles: Q Cycle Activity: Q1
Decode
1 2 Q2
Read register PCL* NOP
Q3
Execute
Q4
NOP
C Words: 1 1 Q2
Read register 'f' RLCF = = = = = 1110 0110 0 1110 0110 1100 1100 1
register f
Forced NOP
Execute
NOP
Cycles: Q Cycle Activity: Q1
Decode
* Remember reading PCL causes PCLATH to be updated. This will be the high address of where the RETURN instruction is located.
Q3
Execute
Q4
Write to destination
Example: After Interrupt
PC = TOS
RETURN
Example:
REG C REG WREG C
REG,0
Before Instruction
After Instruction
DS30412C-page 132
(c) 1996 Microchip Technology Inc.
PIC17C4X
RLNCF Syntax: Operands: Operation: Status Affected: Encoding: Description: Rotate Left f (no carry) [ label ] RLNCF 0 f 255 d [0,1] f d; f<7> d<0> None
0010 001d ffff ffff
RRCF Syntax: Operands: Operation:
Rotate Right f through Carry [ label ] RRCF f,d 0 f 255 d [0,1] f d; f<0> C; C d<7> C
0001 100d ffff ffff The contents of register 'f' are rotated one bit to the right through the Carry Flag. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'.
f,d
Status Affected: Encoding: Description:
The contents of register 'f' are rotated one bit to the left. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is stored back in register 'f'. register f
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' RLNCF = = = = 0 1110 1011
C Words: Q3
Execute
register f
1 1 Q2
Read register 'f' RRCF = = = = = 1110 0110 0 1110 0110 0111 0011 0
Q4
Write to destination
Cycles: Q Cycle Activity: Q1
Decode
Q3
Execute
Q4
Write to destination
Example:
C REG C REG
REG, 1
Before Instruction
Example:
REG1 C
REG1,0
Before Instruction
After Instruction
1101 0111
After Instruction
REG1 WREG C
(c) 1996 Microchip Technology Inc.
DS30412C-page 133
PIC17C4X
RRNCF Syntax: Operands: Operation: Status Affected: Encoding: Description: Rotate Right f (no carry) [ label ] RRNCF f,d 0 f 255 d [0,1] f d; f<0> d<7> None
0010 000d ffff ffff The contents of register 'f' are rotated one bit to the right. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed back in register 'f'. register f
SETF Syntax: Operands: Operation: Status Affected: Encoding: Description:
Set f [ label ] SETF f,s 0 f 255 s [0,1] FFh f; FFh d None
0010 101s ffff ffff If 's' is 0, both the data memory location 'f' and WREG are set to FFh. If 's' is 1 only the data memory location 'f' is set to FFh.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f'
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' RRNCF = = = =
Q3
Execute
Q4
Write register 'f' and other specified register
Q3
Execute
Q4
Write to destination
Example 1:
WREG REG WREG REG
REG, 1
Before Instruction
? 1101 0111 0 1110 1011 RRNCF = = = = REG, 0
Example1:
REG WREG REG WREG = =
SETF 0xDA 0x05
REG, 0
Before Instruction
After Instruction
After Instruction
= 0xFF = 0xFF SETF REG, 1 = = = = 0xDA 0x05 0xFF 0x05
Example 2:
WREG REG WREG REG
Example2:
REG WREG REG WREG
Before Instruction
? 1101 0111 1110 1011 1101 0111
Before Instruction
After Instruction
After Instruction
DS30412C-page 134
(c) 1996 Microchip Technology Inc.
PIC17C4X
SLEEP Syntax: Operands: Operation: Enter SLEEP mode [ label ] SLEEP None 00h WDT; 0 WDT postscaler; 1 TO; 0 PD TO, PD
0000 0000 0000 0011 The power down status bit (PD) is cleared. The time-out status bit (TO) is set. Watchdog Timer and its prescaler are cleared. The processor is put into SLEEP mode with the oscillator stopped.
SUBLW Syntax: Operands: Operation: Status Affected: Encoding: Description:
Subtract WREG from Literal [ label ] SUBLW k 0 k 255 k - (WREG) (WREG) OV, C, DC, Z
1011 0010 kkkk kkkk WREG is subtracted from the eight bit literal 'k'. The result is placed in WREG.
Status Affected: Encoding: Description:
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'k' SUBLW = = = = = 1 ? 1 1 0
Q3
Execute
Q4
Write to WREG
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register PCLATH SLEEP ? ? 1 0
Example 1: Q3
Execute
0x02
Before Instruction Q4
NOP WREG C WREG C Z
After Instruction
; result is positive
Example:
TO = PD = TO = PD =
Before Instruction
Example 2: Before Instruction
WREG C WREG C Z = = = = = 2 ? 0 1 1
After Instruction
After Instruction
; result is zero
If WDT causes wake-up, this bit is cleared
Example 3: Before Instruction
WREG C WREG C Z = = = = = 3 ? FF ; (2's complement) 0 ; result is negative 1
After Instruction
(c) 1996 Microchip Technology Inc.
DS30412C-page 135
PIC17C4X
SUBWF Syntax: Operands: Operation: Status Affected: Encoding: Description: Subtract WREG from f [ label ] SUBWF f,d 0 f 255 d [0,1] (f) - (W) (dest) OV, C, DC, Z
0000 010d ffff ffff Subtract WREG from register 'f' (2's complement method). If 'd' is 0 the result is stored in WREG. If 'd' is 1 the result is stored back in register 'f'.
SUBWFB Syntax: Operands: Operation: Status Affected: Encoding: Description:
Subtract WREG from f with Borrow [ label ] SUBWFB f,d 0 f 255 d [0,1] (f) - (W) - C (dest) OV, C, DC, Z
0000 001d ffff ffff Subtract WREG and the carry flag (borrow) from register 'f' (2's complement method). If 'd' is 0 the result is stored in WREG. If 'd' is 1 the result is stored back in register 'f'.
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' SUBWF = = = = = = = 3 2 ? 1 2 1 0
Words: Q3
Execute
1 1 Q2
Read register 'f' SUBWFB = = = = = = = 0x19 0x0D 1 0x0C 0x0D 1 0
Q4
Write to destination
Cycles: Q Cycle Activity: Q1
Decode
Q3
Execute
Q4
Write to destination
Example 1:
REG1 WREG C REG1 WREG C Z
REG1, 1
Before Instruction
Example 1:
REG1 WREG C ; result is positive REG1 WREG C Z
REG1, 1 (0001 1001) (0000 1101)
Before Instruction
After Instruction
After Instruction
(0000 1011) (0000 1101) ; result is positive REG1,0 (0001 1011) (0001 1010)
Example 2: Before Instruction
REG1 WREG C REG1 WREG C Z = = = = = = = 2 2 ? 0 2 1 1
Example2:
REG1 WREG C ; result is zero REG1 WREG C Z
SUBWFB = = = = = = = 0x1B 0x1A 0 0x1B 0x00 1 1
Before Instruction
After Instruction
After Instruction
(0001 1011) ; result is zero REG1,1 (0000 0011) (0000 1101)
Example 3: Before Instruction
REG1 WREG C REG1 WREG C Z = = = = = = = 1 2 ? FF 2 0 0
Example3:
REG1 WREG C ; result is negative REG1 WREG C Z
SUBWFB = = = = = = = 0x03 0x0E 1 0xF5 0x0E 0 0
Before Instruction
After Instruction
After Instruction
(1111 0100) [2's comp] (0000 1101) ; result is negative
DS30412C-page 136
(c) 1996 Microchip Technology Inc.
PIC17C4X
SWAPF Syntax: Operands: Operation: Status Affected: Encoding: Description: Swap f [ label ] SWAPF f,d 0 f 255 d [0,1] f<3:0> dest<7:4>; f<7:4> dest<3:0> None
0001 110d ffff ffff The upper and lower nibbles of register 'f' are exchanged. If 'd' is 0 the result is placed in WREG. If 'd' is 1 the result is placed in register 'f'.
TABLRD Syntax: Operands:
Table Read [ label ] TABLRD t,i,f 0 f 255 i [0,1] t [0,1] If t = 1, TBLATH f; If t = 0, TBLATL f; Prog Mem (TBLPTR) TBLAT; If i = 1, TBLPTR + 1 TBLPTR None
1010 1. 10ti ffff ffff A byte of the table latch (TBLAT) is moved to register file 'f'. If t = 0: the high byte is moved; If t = 1: the low byte is moved Then the contents of the program memory location pointed to by the 16-bit Table Pointer (TBLPTR) is loaded into the 16-bit Table Latch (TBLAT). If i = 1: TBLPTR is incremented; If i = 0: TBLPTR is not incremented
Operation:
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f' SWAPF = = 0x53 0x35
Status Affected: Encoding: Description:
Q3
Execute
Q4
Write to destination 2.
Example:
REG REG
REG,
0
Before Instruction After Instruction Words: Cycles: Q Cycle Activity: Q1
Decode 3.
1 2 (3 cycle if f = PCL) Q2
Read register TBLATH or TBLATL
Q3
Execute
Q4
Write register 'f'
(c) 1996 Microchip Technology Inc.
DS30412C-page 137
PIC17C4X
TABLRD Example1: Table Read
TABLRD 1, 1, REG ; = = = = = = = = = = 0x53 0xAA 0x55 0xA356 0x1234 0xAA 0x12 0x34 0xA357 0x5678
TABLWT Syntax: Operands:
Table Write [ label ] TABLWT t,i,f 0 f 255 i [0,1] t [0,1] If t = 0, f TBLATL; If t = 1, f TBLATH; TBLAT Prog Mem (TBLPTR); If i = 1, TBLPTR + 1 TBLPTR None
1010 1. 11ti ffff ffff Load value in 'f' into 16-bit table latch (TBLAT) If t = 0: load into low byte; If t = 1: load into high byte The contents of TBLAT is written to the program memory location pointed to by TBLPTR If TBLPTR points to external program memory location, then the instruction takes two-cycle If TBLPTR points to an internal EPROM location, then the instruction is terminated when an interrupt is received.
Before Instruction
REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR) REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR)
Operation:
After Instruction (table write completion)
Status Affected: Encoding: Description:
Example2:
TABLRD
0, 0, REG ; = = = = = = = = = = 0x53 0xAA 0x55 0xA356 0x1234 0x55 0x12 0x34 0xA356 0x1234
Before Instruction
REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR) REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR)
2.
After Instruction (table write completion)
Note:
The MCLR/VPP pin must be at the programming voltage for successful programming of internal memory. If MCLR/VPP = VDD the programming sequence of internal memory will be executed, but will not be successful (although the internal memory location may be disturbed) 3. The TBLPTR can be automatically incremented If i = 0; TBLPTR is not incremented If i = 1; TBLPTR is incremented
Words: Cycles: Q Cycle Activity: Q1
Decode
1 2 (many if write is to on-chip EPROM program memory) Q2
Read register 'f'
Q3
Execute
Q4
Write register TBLATH or TBLATL
DS30412C-page 138
(c) 1996 Microchip Technology Inc.
PIC17C4X
TABLWT Example1: Table Write
TABLWT 0, 1, REG = = = = = = = = = = 0x53 0xAA 0x55 0xA356 0xFFFF 0x53 0x53 0x55 0xA357 0x5355
TLRD Syntax: Operands: Operation:
Table Latch Read [ label ] TLRD t,f 0 f 255 t [0,1] If t = 0, TBLATL f; If t = 1, TBLATH f None
1010 00tx ffff ffff Read data from 16-bit table latch (TBLAT) into file register 'f'. Table Latch is unaffected. If t = 1; high byte is read If t = 0; low byte is read This instruction is used in conjunction with TABLRD to transfer data from program memory to data memory.
Before Instruction
REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR) REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR - 1)
After Instruction (table write completion) Status Affected: Encoding: Description:
Example 2:
TABLWT
1, 0, REG = = = = = = = = = = 0x53 0xAA 0x55 0xA356 0xFFFF 0x53 0xAA 0x53 0xA356 0xAA53
Before Instruction
REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR) REG TBLATH TBLATL TBLPTR MEMORY(TBLPTR)
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register TBLATH or TBLATL TLRD = = =
After Instruction (table write completion)
Q3
Execute
Q4
Write register 'f'
Program Memory
15 TBLPTR 15 8 7
0
Data Memory
Example:
t RAM TBLAT
t, RAM
Before Instruction
0
0 ? 0x00AF
(TBLATH = 0x00) (TBLATL = 0xAF)
16 bits
TBLAT
8 bits
After Instruction
RAM TBLAT = = 0xAF 0x00AF (TBLATH = 0x00) (TBLATL = 0xAF)
Before Instruction
t RAM TBLAT = = = 1 ? 0x00AF
(TBLATH = 0x00) (TBLATL = 0xAF)
After Instruction
RAM TBLAT = = 0x00 0x00AF (TBLATH = 0x00) (TBLATL = 0xAF)
Program Memory
15 TBLPTR 15 8 7
0
Data Memory
0
16 bits
TBLAT
8 bits
(c) 1996 Microchip Technology Inc.
DS30412C-page 139
PIC17C4X
TLWT Syntax: Operands: Operation: Table Latch Write [ label ] TLWT t,f 0 f 255 t [0,1] If t = 0, f TBLATL; If t = 1, f TBLATH None
1010 01tx ffff ffff Data from file register 'f' is written into the 16-bit table latch (TBLAT). If t = 1; high byte is written If t = 0; low byte is written This instruction is used in conjunction with TABLWT to transfer data from data memory to program memory.
TSTFSZ Syntax: Operands: Operation: Status Affected: Encoding: Description:
Test f, skip if 0 [ label ] TSTFSZ f 0 f 255 skip if f = 0 None
0011 0011 ffff ffff If 'f' = 0, the next instruction, fetched during the current instruction execution, is discarded and an NOP is executed making this a two-cycle instruction.
Status Affected: Encoding: Description:
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 (2) Q2
Read register 'f'
Q3
Execute
Q4
NOP
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read register 'f'
If skip: Q1
Forced NOP
Q2
NOP HERE NZERO ZERO
Q3
Execute TSTFSZ : : CNT
Q4
NOP
Q3
Execute
Q4
Write register TBLATH or TBLATL
Example:
Before Instruction
PC = Address(HERE)
Example:
t RAM TBLAT = = =
TLWT
t, RAM
After Instruction
If CNT PC If CNT PC = = = 0x00, Address (ZERO) 0x00, Address (NZERO)
Before Instruction
0 0xB7 0x0000
(TBLATH = 0x00) (TBLATL = 0x00)
After Instruction
RAM TBLAT = = 0xB7 0x00B7 (TBLATH = 0x00) (TBLATL = 0xB7)
Before Instruction
t RAM TBLAT = = = 1 0xB7 0x0000
(TBLATH = 0x00) (TBLATL = 0x00)
After Instruction
RAM TBLAT = = 0xB7 0xB700 (TBLATH = 0xB7) (TBLATL = 0x00)
DS30412C-page 140
(c) 1996 Microchip Technology Inc.
PIC17C4X
XORLW Syntax: Operands: Operation: Status Affected: Encoding: Description: Exclusive OR Literal with WREG [ label ] XORLW k 0 k 255 (WREG) .XOR. k (WREG) Z
1011 0100 kkkk kkkk The contents of WREG are XOR'ed with the 8-bit literal 'k'. The result is placed in WREG.
XORWF Syntax: Operands: Operation: Status Affected: Encoding: Description:
Exclusive OR WREG with f [ label ] XORWF 0 f 255 d [0,1] (WREG) .XOR. (f) (dest) Z
0000 110d ffff ffff Exclusive OR the contents of WREG with register 'f'. If 'd' is 0 the result is stored in WREG. If 'd' is 1 the result is stored back in the register 'f'.
f,d
Words: Cycles: Q Cycle Activity: Q1
Decode
1 1 Q2
Read literal 'k' XORLW = = 0xB5 0x1A
Words: Cycles: Q3
Execute
1 1 Q2
Read register 'f' XORWF = = = = 0xAF 0xB5 0x1A 0xB5
Q4
Write to WREG
Q Cycle Activity: Q1
Decode
Q3
Execute
Q4
Write to destination
Example:
WREG WREG
0xAF
Before Instruction After Instruction
Example:
REG WREG REG WREG
REG, 1
Before Instruction
After Instruction
(c) 1996 Microchip Technology Inc.
DS30412C-page 141
PIC17C4X
NOTES:
DS30412C-page 142
(c) 1996 Microchip Technology Inc.
PIC17C4X
16.0
16.1
DEVELOPMENT SUPPORT
Development Tools
16.3
ICEPIC: Low-cost PIC16CXXX In-Circuit Emulator
The PIC16/17 microcontrollers are supported with a full range of hardware and software development tools: * PICMASTER/PICMASTER CE Real-Time In-Circuit Emulator * ICEPIC Low-Cost PIC16C5X and PIC16CXXX In-Circuit Emulator * PRO MATE(R) II Universal Programmer * PICSTART(R) Plus Entry-Level Prototype Programmer * PICDEM-1 Low-Cost Demonstration Board * PICDEM-2 Low-Cost Demonstration Board * PICDEM-3 Low-Cost Demonstration Board * MPASM Assembler * MPLAB-SIM Software Simulator * MPLAB-C (C Compiler) * Fuzzy logic development system (fuzzyTECH(R)-MP)
ICEPIC is a low-cost in-circuit emulator solution for the Microchip PIC16C5X and PIC16CXXX families of 8-bit OTP microcontrollers. ICEPIC is designed to operate on PC-compatible machines ranging from 286-AT(R) through PentiumTM based machines under Windows 3.x environment. ICEPIC features real time, non-intrusive emulation.
16.4
PRO MATE II: Universal Programmer
The PRO MATE II Universal Programmer is a full-featured programmer capable of operating in stand-alone mode as well as PC-hosted mode. The PRO MATE II has programmable VDD and VPP supplies which allows it to verify programmed memory at VDD min and VDD max for maximum reliability. It has an LCD display for displaying error messages, keys to enter commands and a modular detachable socket assembly to support various package types. In standalone mode the PRO MATE II can read, verify or program PIC16C5X, PIC16CXXX, PIC17CXX and PIC14000 devices. It can also set configuration and code-protect bits in this mode.
16.2
PICMASTER: High Performance Universal In-Circuit Emulator with MPLAB IDE
The PICMASTER Universal In-Circuit Emulator is intended to provide the product development engineer with a complete microcontroller design tool set for all microcontrollers in the PIC12C5XX, PIC14000, PIC16C5X, PIC16CXXX and PIC17CXX families. PICMASTER is supplied with the MPLABTM Integrated Development Environment (IDE), which allows editing, "make" and download, and source debugging from a single environment. Interchangeable target probes allow the system to be easily reconfigured for emulation of different processors. The universal architecture of the PICMASTER allows expansion to support all new Microchip microcontrollers. The PICMASTER Emulator System has been designed as a real-time emulation system with advanced features that are generally found on more expensive development tools. The PC compatible 386 (and higher) machine platform and Microsoft Windows(R) 3.x environment were chosen to best make these features available to you, the end user. A CE compliant version of PICMASTER is available for European Union (EU) countries.
16.5
PICSTART Plus Entry Level Development System
The PICSTART programmer is an easy-to-use, lowcost prototype programmer. It connects to the PC via one of the COM (RS-232) ports. MPLAB Integrated Development Environment software makes using the programmer simple and efficient. PICSTART Plus is not recommended for production programming. PICSTART Plus supports all PIC12C5XX, PIC14000, PIC16C5X, PIC16CXXX and PIC17CXX devices with up to 40 pins. Larger pin count devices such as the PIC16C923 and PIC16C924 may be supported with an adapter socket.
(c) 1996 Microchip Technology Inc.
DS30412C-page 143
This document was created with FrameMaker 4 0 4
PIC17C4X
16.6 PICDEM-1 Low-Cost PIC16/17 Demonstration Board
include an RS-232 interface, push-button switches, a potentiometer for simulated analog input, a thermistor and separate headers for connection to an external LCD module and a keypad. Also provided on the PICDEM-3 board is an LCD panel, with 4 commons and 12 segments, that is capable of displaying time, temperature and day of the week. The PICDEM-3 provides an additional RS-232 interface and Windows 3.1 software for showing the demultiplexed LCD signals on a PC. A simple serial interface allows the user to construct a hardware demultiplexer for the LCD signals. PICDEM-3 will be available in the 3rd quarter of 1996.
The PICDEM-1 is a simple board which demonstrates the capabilities of several of Microchip's microcontrollers. The microcontrollers supported are: PIC16C5X (PIC16C54 to PIC16C58A), PIC16C61, PIC16C62X, PIC16C71, PIC16C8X, PIC17C42, PIC17C43 and PIC17C44. All necessary hardware and software is included to run basic demo programs. The users can program the sample microcontrollers provided with the PICDEM-1 board, on a PRO MATE II or PICSTART-16B programmer, and easily test firmware. The user can also connect the PICDEM-1 board to the PICMASTER emulator and download the firmware to the emulator for testing. Additional prototype area is available for the user to build some additional hardware and connect it to the microcontroller socket(s). Some of the features include an RS-232 interface, a potentiometer for simulated analog input, push-button switches and eight LEDs connected to PORTB.
16.9
MPLAB Integrated Development Environment Software
The MPLAB IDE Software brings an ease of software development previously unseen in the 8-bit microcontroller market. MPLAB is a windows based application which contains: * A full featured editor * Three operating modes - editor - emulator - simulator * A project manager * Customizable tool bar and key mapping * A status bar with project information * Extensive on-line help MPLAB allows you to: * Edit your source files (either assembly or `C') * One touch assemble (or compile) and download to PIC16/17 tools (automatically updates all project information) * Debug using: - source files - absolute listing file * Transfer data dynamically via DDE (soon to be replaced by OLE) * Run up to four emulators on the same PC The ability to use MPLAB with Microchip's simulator allows a consistent platform and the ability to easily switch from the low cost simulator to the full featured emulator with minimal retraining due to development tools.
16.7
PICDEM-2 Low-Cost PIC16CXX Demonstration Board
The PICDEM-2 is a simple demonstration board that supports the PIC16C62, PIC16C64, PIC16C65, PIC16C73 and PIC16C74 microcontrollers. All the necessary hardware and software is included to run the basic demonstration programs. The user can program the sample microcontrollers provided with the PICDEM-2 board, on a PRO MATE II programmer or PICSTART-16C, and easily test firmware. The PICMASTER emulator may also be used with the PICDEM-2 board to test firmware. Additional prototype area has been provided to the user for adding additional hardware and connecting it to the microcontroller socket(s). Some of the features include a RS-232 interface, push-button switches, a potentiometer for simulated analog input, a Serial EEPROM to demonstrate usage of the I2C bus and separate headers for connection to an LCD module and a keypad.
16.8
PICDEM-3 Low-Cost PIC16CXXX Demonstration Board
The PICDEM-3 is a simple demonstration board that supports the PIC16C923 and PIC16C924 in the PLCC package. It will also support future 44-pin PLCC microcontrollers with a LCD Module. All the necessary hardware and software is included to run the basic demonstration programs. The user can program the sample microcontrollers provided with the PICDEM-3 board, on a PRO MATE II programmer or PICSTART Plus with an adapter socket, and easily test firmware. The PICMASTER emulator may also be used with the PICDEM-3 board to test firmware. Additional prototype area has been provided to the user for adding hardware and connecting it to the microcontroller socket(s). Some of the features
16.10
Assembler (MPASM)
The MPASM Universal Macro Assembler is a PChosted symbolic assembler. It supports all microcontroller series including the PIC12C5XX, PIC14000, PIC16C5X, PIC16CXXX, and PIC17CXX families. MPASM offers full featured Macro capabilities, conditional assembly, and several source and listing formats. It generates various object code formats to support Microchip's development tools as well as third party programmers.
DS30412C-page 144
(c) 1996 Microchip Technology Inc.
PIC17C4X
MPASM allow full symbolic debugging from the Microchip Universal Emulator System (PICMASTER). MPASM has the following features to assist in developing software for specific use applications. * Provides translation of Assembler source code to object code for all Microchip microcontrollers. * Macro assembly capability. * Produces all the files (Object, Listing, Symbol, and special) required for symbolic debug with Microchip's emulator systems. * Supports Hex (default), Decimal and Octal source and listing formats. MPASM provides a rich directive language to support programming of the PIC16/17. Directives are helpful in making the development of your assemble source code shorter and more maintainable. Both versions include Microchip's fuzzyLABTM demonstration board for hands-on experience with fuzzy logic systems implementation.
16.14
MP-DriveWayTM - Application Code Generator
MP-DriveWay is an easy-to-use Windows-based Application Code Generator. With MP-DriveWay you can visually configure all the peripherals in a PIC16/17 device and, with a click of the mouse, generate all the initialization and many functional code modules in C language. The output is fully compatible with Microchip's MPLAB-C C compiler. The code produced is highly modular and allows easy integration of your own code. MP-DriveWay is intelligent enough to maintain your code through subsequent code generation.
16.15
SEEVAL(R) Evaluation and Programming System
16.11
Software Simulator (MPLAB-SIM)
The SEEVAL SEEPROM Designer's Kit supports all Microchip 2-wire and 3-wire Serial EEPROMs. The kit includes everything necessary to read, write, erase or program special features of any Microchip SEEPROM product including Smart SerialsTM and secure serials. The Total EnduranceTM Disk is included to aid in tradeoff analysis and reliability calculations. The total kit can significantly reduce time-to-market and result in an optimized system.
The MPLAB-SIM Software Simulator allows code development in a PC host environment. It allows the user to simulate the PIC16/17 series microcontrollers on an instruction level. On any given instruction, the user may examine or modify any of the data areas or provide external stimulus to any of the pins. The input/ output radix can be set by the user and the execution can be performed in; single step, execute until break, or in a trace mode. MPLAB-SIM fully supports symbolic debugging using MPLAB-C and MPASM. The Software Simulator offers the low cost flexibility to develop and debug code outside of the laboratory environment making it an excellent multi-project software development tool.
16.16
TrueGauge(R) Intelligent Battery Management
16.12
C Compiler (MPLAB-C)
The MPLAB-C Code Development System is a complete `C' compiler and integrated development environment for Microchip's PIC16/17 family of microcontrollers. The compiler provides powerful integration capabilities and ease of use not found with other compilers. For easier source level debugging, the compiler provides symbol information that is compatible with the MPLAB IDE memory display (PICMASTER emulator software versions 1.13 and later).
The TrueGauge development tool supports system development with the MTA11200B TrueGauge Intelligent Battery Management IC. System design verification can be accomplished before hardware prototypes are built. User interface is graphically-oriented and measured data can be saved in a file for exporting to Microsoft Excel.
16.17
KEELOQ(R) Evaluation and Programming Tools
KEELOQ evaluation and programming tools support Microchips HCS Secure Data Products. The HCS evaluation kit includes an LCD display to show changing codes, a decoder to decode transmissions, and a programming interface to program test transmitters.
16.13
Fuzzy Logic Development System (fuzzyTECH-MP)
fuzzyTECH-MP fuzzy logic development tool is available in two versions - a low cost introductory version, MP Explorer, for designers to gain a comprehensive working knowledge of fuzzy logic system design; and a full-featured version, fuzzyTECH-MP, edition for implementing more complex systems.
(c) 1996 Microchip Technology Inc.
DS30412C-page 145
Product
MPLABTM C Compiler
TABLE 16-1:
PIC12C508, 509 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006005 SW006006 SW006006 SW006006 SW006006 SW006006 SW006006 SW006006 -- SW006006 SW006006 SW006006 SW006006 -- SW006006 -- --
** MPLABTM Integrated Development Environment SW007002 SW006005 MP-DriveWay Applications Code Generator --
fuzzyTECH(R)-MP Explorer/Edition Fuzzy Logic Dev. Tool --
DS30412C-page 146
DV005001/ DV005002 DV005001/ DV005002 DV005001/ DV005002 DV005001/ DV005002 DV005001/ DV005002 DV005001/ DV005002 -- DV005001/ DV005002 DV005001/ DV005002 -- DV005001/ DV005002 DV005001/ DV005002 DV005001/ DV005002 DV005001/ DV005002 DV005001/ DV005002 ****PRO MATETM PICSTART(R) Lite PICSTART(R) Plus *** PICMASTER(R)/ ICEPIC Low-Cost PICMASTER-CE Ultra Low-Cost Low-Cost II Universal In-Circuit In-Circuit Dev. Kit Universal Microchip Emulator Emulator Dev. Kit Programmer EM167015/ -- DV007003 -- DV003001 EM167101 EM147001/ -- DV007003 -- DV003001 EM147101 EM167015/ EM167201 DV007003 DV162003 DV003001 EM167101 EM167033/ --DV007003 -- DV003001 EM167113 EM167021/ EM167205 DV007003 DV162003 DV003001 N/A EM167025/ EM167203 DV007003 DV162002 DV003001 EM167103 EM167023/ EM167202 DV007003 DV162003 DV003001 EM167109 EM167025/ EM167204 DV007003 DV162002 DV003001 EM167103 EM167035/ --DV007003 DV162002 DV003001 EM167105 EM167027/ EM167205 DV007003 DV162003 DV003001 EM167105 EM167027/ -- DV007003 DV162003 DV003001 EM167105 EM167025/ -- DV007003 DV162002 DV003001 EM167103 EM167029/ -- DV007003 DV162003 DV003001 EM167107 EM167029/ EM167206 DV007003 DV162003 DV003001 EM167107 EM167029/ -- DV007003 DV162003 DV003001 EM167107 EM167031/ -- DV007003 -- DV003001 EM167111 EM177007/ -- DV007003 -- DV003001 EM177107 ***All PICMASTER and PICMASTER-CE ordering part numbers above include PRO MATE II programmer ****PRO MATE socket modules are ordered separately. See development systems ordering guide for specific ordering part numbers Hopping Code Security Programmer Kit N/A N/A N/A N/A PG306001 Hopping Code Security Eval/Demo Kit N/A N/A DM303001 SEEVAL(R) Designers Kit DV243001 DV114001 N/A
PIC14000
SW007002
PIC17C4X
PIC16C52, 54, 54A, 55, 56, 57, 58A PIC16C554, 556, 558
SW007002
SW007002
PIC16C61
SW007002
PIC16C62, 62A, 64, 64A PIC16C620, 621, 622
SW007002
SW007002
PIC16C63, 65, 65A, 73, 73A, 74, 74A PIC16C642, 662*
SW007002
SW007002
PIC16C71
SW007002
PIC16C710, 711
SW007002
DEVELOPMENT TOOLS FROM MICROCHIP
PIC16C72
SW007002
PIC16F83
SW007002
PIC16C84
SW007002
PIC16F84
SW007002
PIC16C923, 924*
SW007002
PIC17C42, SW007002 SW006005 SW006006 42A, 43, 44 *Contact Microchip Technology for availability date **MPLAB Integrated Development Environment includes MPLAB-SIM Simulator and MPASM Assembler
(c) 1996 Microchip Technology Inc.
Product All 2 wire and 3 wire Serial EEPROM's MTA11200B HCS200, 300, 301 *
TRUEGAUGE(R) Development Kit N/A
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
17.0
PIC17C42 ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings Ambient temperature under bias..................................................................................................................-55 to +125C Storage temperature ............................................................................................................................... -65C to +150C Voltage on VDD with respect to VSS ................................................................................................................ 0 to +7.5V Voltage on MCLR with respect to VSS (Note 2) ..........................................................................................-0.6V to +14V Voltage on RA2 and RA3 with respect to VSS..............................................................................................-0.6V to +12V Voltage on all other pins with respect to VSS ..................................................................................... -0.6V to VDD + 0.6V Total power dissipation (Note 1).................................................................................................................................1.0W Maximum current out of VSS pin(s) - Total .............................................................................................................250 mA Maximum current into VDD pin(s) - Total ................................................................................................................200 mA Input clamp current, IIK (VI < 0 or VI > VDD) ......................................................................................................................20 mA Output clamp current, IOK (VO < 0 or VO > VDD) ...............................................................................................................20 mA Maximum output current sunk by any I/O pin (except RA2 and RA3)......................................................................35 mA Maximum output current sunk by RA2 or RA3 pins .................................................................................................60 mA Maximum output current sourced by any I/O pin .....................................................................................................20 mA Maximum current sunk by PORTA and PORTB (combined)..................................................................................150 mA Maximum current sourced by PORTA and PORTB (combined).............................................................................100 mA Maximum current sunk by PORTC, PORTD and PORTE (combined)...................................................................150 mA Maximum current sourced by PORTC, PORTD and PORTE (combined)..............................................................100 mA Note 1: Power dissipation is calculated as follows: Pdis = VDD x {IDD - IOH} + {(VDD-VOH) x IOH} + (VOL x IOL) Note 2: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up. Thus, a series resistor of 50-100 should be used when applying a "low" level to the MCLR pin rather than pulling this pin directly to VSS. NOTICE: Stresses above those listed under "Absolute Maximum Ratings" may cause permanent damage to the device. This is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for extended periods may affect device reliability.
(c) 1996 Microchip Technology Inc.
DS30412C-page 147
This document was created with FrameMaker 4 0 4
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 TABLE 17-1:
OSC RC VDD: IDD: IPD: Freq: VDD: IDD: IPD: Freq: VDD: IDD: IPD: Freq: VDD: IDD: IPD: Freq:
CROSS REFERENCE OF DEVICE SPECS FOR OSCILLATOR CONFIGURATIONS AND FREQUENCIES OF OPERATION (COMMERCIAL DEVICES)
PIC17C42-16 4.5V to 5.5V 6 mA max. 5 A max. at 5.5V (WDT disabled) 4 MHz max. 4.5V to 5.5V 24 mA max. 5 A max. at 5.5V (WDT disabled) 16 MHz max. 4.5V to 5.5V 24 mA max. 5 A max. at 5.5V (WDT disabled) 16 MHz max. 4.5V to 5.5V 150 A max. at 32 kHz (WDT enabled) 5 A max. at 5.5V (WDT disabled) 2 MHz max. VDD: IDD: IPD: Freq: VDD: IDD: IPD: Freq: VDD: IDD: IPD: Freq: VDD: IDD: IPD: Freq: PIC17C42-25 4.5V to 5.5V 6 mA max. 5 A max. at 5.5V (WDT disabled) 4 MHz max. 4.5V to 5.5V 38 mA max. 5 A max. at 5.5V (WDT disabled) 25 MHz max. 4.5V to 5.5V 38 mA max. 5 A max. at 5.5V (WDT disabled) 25 MHz max. 4.5V to 5.5V 150 A max. at 32 kHz (WDT enabled) 5 A max. at 5.5V (WDT disabled) 2 MHz max.
XT
EC
LF
DS30412C-page 148
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 17.1 DC CHARACTERISTICS: PIC17C42-16 (Commercial, Industrial) PIC17C42-25 (Commercial, Industrial)
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +85C for industrial and 0C TA +70C for commercial Min 4.5 1.5 * - Typ Max - - VSS 5.5 - - Units V V V Conditions Device in SLEEP mode See section on Power-on Reset for details
DC CHARACTERISTICS Parameter No. D001 D002 D003
Sym VDD VDR VPOR
Characteristic Supply Voltage RAM Data Retention Voltage (Note 1) VDD start voltage to ensure internal Power-on Reset signal VDD rise rate to ensure internal Power-on Reset signal Supply Current (Note 2)
D004
SVDD
0.060*
-
-
mV/ms See section on Power-on Reset for details mA mA mA mA A FOSC = 4 MHz (Note 4) FOSC = 8 MHz FOSC = 16 MHz FOSC = 25 MHz FOSC = 32 kHz WDT enabled (EC osc configuration) VDD = 5.5V, WDT enabled VDD = 5.5V, WDT disabled
D010 D011 D012 D013 D014
IDD
- - - - -
3 6 11 19 95
6 12 * 24 * 38 150
D020 IPD Power-down Current - 10 40 A D021 (Note 3) - <1 5 A * These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. Note 1: This is the limit to which VDD can be lowered in SLEEP mode without losing RAM data. 2: The supply current is mainly a function of the operating voltage and frequency. Other factors such as I/O pin loading and switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current consumption. The test conditions for all IDD measurements in active operation mode are: OSC1 = external square wave, from rail to rail; all I/O pins tristated, pulled to VDD or VSS, T0CKI = VDD, MCLR = VDD; WDT enabled/disabled as specified. Current consumed from the oscillator and I/O's driving external capacitive or resistive loads need to be considered. For the RC oscillator, the current through the external pull-up resistor (R) can be estimated as: VDD / (2 * R). For capacitive loads, The current can be estimated (for an individual I/O pin) as (CL * VDD) * f CL = Total capacitive load on the I/O pin; f = average frequency on the I/O pin switches. The capacitive currents are most significant when the device is configured for external execution (includes extended microcontroller mode). 3: The power-down current in SLEEP mode does not depend on the oscillator type. Power-down current is measured with the part in SLEEP mode, all I/O pins in hi-impedance state and tied to VDD or VSS. 4: For RC osc configuration, current through Rext is not included. The current through the resistor can be estimated by the formula IR = VDD/2Rext (mA) with Rext in kOhm.
(c) 1996 Microchip Technology Inc.
DS30412C-page 149
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 17.2 DC CHARACTERISTICS: PIC17C42-16 (Commercial, Industrial) PIC17C42-25 (Commercial, Industrial)
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +85C for industrial and 0C TA +70C for commercial Operating voltage VDD range as described in Section 17.1 Characteristic Input Low Voltage I/O ports with TTL buffer with Schmitt Trigger buffer Min Typ Max Units Conditions
DC CHARACTERISTICS
Parameter No. Sym VIL D030 D031 D032 D033
VSS VSS Vss -
- - - 0.5VDD
0.8 0.2VDD 0.2VDD -
V V V V Note1
D040 D041 D042 D043 D050
D060
MCLR, OSC1 (in EC and RC mode) OSC1 (in XT, and LF mode) Input High Voltage VIH I/O ports with TTL buffer with Schmitt Trigger buffer MCLR OSC1 (XT, and LF mode) VHYS Hysteresis of Schmitt Trigger inputs Input Leakage Current (Notes 2, 3) IIL I/O ports (except RA2, RA3)
- 2.0 - 0.8VDD - 0.8VDD - - 0.5VDD 0.15VDD* -
VDD VDD VDD - -
V V V V V
Note1
-
-
1
A
Vss VPIN VDD, I/O Pin at hi-impedance PORTB weak pull-ups disabled VPIN = Vss or VPIN = VDD Vss VRA2, VRA3 12V Vss VPIN VDD VMCLR = VPP = 12V (when not programming)
D061 D062 D063 D064 D070 * Note 1: 2: 3: 4:
MCLR RA2, RA3 OSC1, TEST MCLR
- - -
- - -
2 2 1 10
A A A A
5: 6:
60 200 400 A VPIN = VSS, RBPU = 0 IPURB PORTB weak pull-up current These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. Design guidance to attain the AC timing specifications. These loads are not tested. In RC oscillator configuration, the OSC1 pin is a Schmitt Trigger input. It is not recommended that the PIC17CXX devices be driven with external clock in RC mode. The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. Negative current is defined as coming out of the pin. These specifications are for the programming of the on-chip program memory EPROM through the use of the table write instructions. The complete programming specifications can be found in: PIC17CXX Programming Specifications (Literature number DS30139). The MCLR/Vpp pin may be kept in this range at times other than programming, but this is not recommended. For TTL buffers, the better of the two specifications may be used.
DS30412C-page 150
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +85C for industrial and 0C TA +70C for commercial Operating voltage VDD range as described in Section 17.1 Characteristic Output Low Voltage I/O ports (except RA2 and RA3) with TTL buffer Min - - Typ - - - - Max 0.1VDD 0.4 3.0 0.4 Units V V V V Conditions IOL = 4 mA IOL = 6 mA, VDD = 4.5V Note 6 IOL = 60.0 mA, VDD = 5.5V IOL = 2 mA, VDD = 4.5V
DC CHARACTERISTICS
Parameter No. Sym D080 D081 D082 D083 VOL
D090 D091 D092 D093
VOH
RA2 and RA3 - OSC2/CLKOUT - (RC and EC osc modes) Output High Voltage (Note 3) I/O ports (except RA2 and RA3) 0.9VDD with TTL buffer 2.4 RA2 and RA3 - 2.4
- - - -
- - 12 -
V V V V
D100
OSC2/CLKOUT (RC and EC osc modes) Capacitive Loading Specs on Output Pins COSC2 OSC2 pin
IOH = -2 mA IOH = -6.0 mA, VDD = 4.5V Note 6 Pulled-up to externally applied voltage IOH = -5 mA, VDD = 4.5V
-
-
25
pF
In EC or RC osc modes when OSC2 pin is outputting CLKOUT. External clock is used to drive OSC1.
D101 D102
CIO CAD
All I/O pins and OSC2 (in RC mode) System Interface Bus (PORTC, PORTD and PORTE)
- -
- -
50 100
pF pF In Microprocessor or Extended Microcontroller mode
* Note 1: 2: 3: 4:
5: 6:
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. Design guidance to attain the AC timing specifications. These loads are not tested. In RC oscillator configuration, the OSC1 pin is a Schmitt Trigger input. It is not recommended that the PIC17CXX devices be driven with external clock in RC mode. The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. Negative current is defined as coming out of the pin. These specifications are for the programming of the on-chip program memory EPROM through the use of the table write instructions. The complete programming specifications can be found in: PIC17CXX Programming Specifications (Literature number DS30139). The MCLR/Vpp pin may be kept in this range at times other than programming, but this is not recommended. For TTL buffers, the better of the two specifications may be used.
(c) 1996 Microchip Technology Inc.
DS30412C-page 151
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +40C Operating voltage VDD range as described in Section 17.1 Characteristic Internal Program Memory Programming Specs (Note 4) D110 D111 D112 D113 D114 * Note 1: 2: 3: 4: VPP Voltage on MCLR/VPP pin VDDP Supply voltage during programming Current into MCLR/VPP pin IPP IDDP Supply current during programming TPROG Programming pulse width 12.75 4.75 - - 10 - 5.0 25 - 100 13.25 5.25 50 30 1000 V V mA mA s Terminated via internal/external interrupt or a reset Note 5 Min Typ Max Units Conditions
DC CHARACTERISTICS Parameter No. Sym
5: 6:
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that the PIC17CXX devices be driven with external clock in RC mode. The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. Negative current is defined as coming out of the pin. These specifications are for the programming of the on-chip program memory EPROM through the use of the table write instructions. The complete programming specifications can be found in: PIC17CXX Programming Specifications (Literature number DS30139). The MCLR/VPP pin may be kept in this range at times other than programming, but is not recommended. For TTL buffers, the better of the two specifications may be used.
Note:
When using the Table Write for internal programming, the device temperature must be less than 40C.
DS30412C-page 152
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 17.3 Timing Parameter Symbology
The timing parameter symbols have been created using one of the following formats: 1. TppS2ppS 2. TppS T F Frequency Lowercase symbols (pp) and their meanings: pp ad Address/Data al ALE cc Capture1 and Capture2 ck CLKOUT or clock dt Data in in INT pin io I/O port mc MCLR oe OE os OSC1 Uppercase symbols and their meanings: S D Driven E Edge F Fall H High I Invalid (Hi-impedance)
T
Time
ost pwrt rb rd rw t0 t123 wdt wr
Oscillator Start-up Timer Power-up Timer PORTB RD RD or WR T0CKI TCLK12 and TCLK3 Watchdog Timer WR
L P R V Z
Low Period Rise Valid Hi-impedance
(c) 1996 Microchip Technology Inc.
DS30412C-page 153
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-1: PARAMETER MEASUREMENT INFORMATION
All timings are measure between high and low measurement points as indicated in the figures below.
INPUT LEVEL CONDITIONS
PORTC, D and E pins VIH = 2.4V VIL = 0.4V Data in valid All other input pins Data in invalid VIH = 0.9VDD VIL = 0.1VDD Data in valid Data in invalid
OUTPUT LEVEL CONDITIONS
0.25V VOH = 0.7VDD VDD/2 VOL = 0.3VDD Data out valid Data out invalid 0.25V 0.25V 0.25V Output driven Output hi-impedance 0.9VDD 0.1VDD Rise Time Fall Time
LOAD CONDITIONS
Load Condition 1 VDD/2 Load Condition 2
RL Pin Pin
CL CL
VSS
VSS
RL = 464 CL 50 pF
DS30412C-page 154
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 17.4 Timing Diagrams and Specifications
FIGURE 17-2: EXTERNAL CLOCK TIMING
Q4 OSC1 1 2 OSC2 3 3 4 4 Q1 Q2 Q3 Q4 Q1
In EC and RC modes only.
TABLE 17-2:
Parameter No.
EXTERNAL CLOCK TIMING REQUIREMENTS
Sym
Fosc
Characteristic
External CLKIN Frequency (Note 1) Oscillator Frequency (Note 1)
Min
DC DC DC 1 1 DC 62.5 40 250 62.5 40 500 160 10
Typ
-- -- -- -- -- -- -- -- -- -- -- -- 4/Fosc --
Max
16 25 4 16 25 2 -- -- -- 1,000 1,000 -- DC --
Units
MHz MHz MHz MHz MHz MHz ns ns ns ns ns ns ns ns
Conditions
EC osc mode - PIC17C42-16 - PIC17C42-25 RC osc mode XT osc mode - PIC17C42-16 - PIC17C42-25 LF osc mode EC osc mode - PIC17C42-16 - PIC17C42-25 RC osc mode XT osc mode - PIC17C42-16 - PIC17C42-25 LF osc mode
1
Tosc
External CLKIN Period (Note 1) Oscillator Period (Note 1)
TCY Instruction Cycle Time (Note 1) TosL, Clock in (OSC1) High or Low Time EC oscillator TosH 4 TosR, Clock in (OSC1) Rise or Fall Time -- -- 5 ns EC oscillator TosF Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. Note 1: Instruction cycle period (TCY) equals four times the input oscillator time-base period. All specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. Exceeding these specified limits may result in unstable oscillator operation and/or higher than expected current consumption. All devices are tested to operate at "min." values with an external clock applied to the OSC1 pin. When an external clock input is used, the "Max." cycle time limit is "DC" (no clock) for all devices.
2 3
(c) 1996 Microchip Technology Inc.
DS30412C-page 155
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-3: CLKOUT AND I/O TIMING
Q4 OSC1 10 OSC2 13 14 22 23 12 16 11 Q1 Q2 Q3
I/O Pin (input) 17 I/O Pin (output) old value 20, 21 In EC and RC modes only. 15 new value
TABLE 17-3:
Parameter No.
10 11 12 13 14 15 16 17 20 21 22 23 *
CLKOUT AND I/O TIMING REQUIREMENTS
Sym Characteristic
OSC1 to CLKOUT OSC1 to CLKOUT CLKOUT rise time CLKOUT fall time CLKOUT to Port out valid Port in valid before CLKOUT Port in hold after CLKOUT OSC1 (Q1 cycle) to Port out valid Port output rise time Port output fall time INT pin high or low time RB7:RB0 change INT high or low time
Min
-- -- -- -- -- 0.25TCY + 25 0 -- -- -- 25 * 25 *
Typ
15 15 5 5 -- -- -- -- 10 10 -- --
Max
30 30 15 15 0.5TCY + 20 -- -- 100 35 35 -- --
Units
ns ns ns ns ns ns ns ns ns ns ns ns
Conditions
Note 1 Note 1 Note 1 Note 1 Note 1 Note 1 Note 1
TosH2ckL TosH2ckH TckR TckF TckH2ioV TioV2ckH TckH2ioI TosH2ioV TioR TioF TinHL TrbHL
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. Note 1: Measurements are taken in EC Mode where OSC2 output = 4 x TOSC = TCY.
DS30412C-page 156
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-4: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER AND POWER-UP TIMER TIMING
VDD MCLR 30 Internal POR 33 PWRT Time-out 32 OSC Time-out Internal RESET Watchdog Timer RESET 35 Address / Data
31
TABLE 17-4:
Parameter No. 30 31 32 33 35 *
RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER AND POWER-UP TIMER REQUIREMENTS
Sym TmcL Twdt Tost Tpwrt Characteristic MCLR Pulse Width (low) Watchdog Timer Time-out Period (Prescale = 1) Oscillation Start-up Timer Period Power-up Timer Period 40 * -- Min 100 * 5* Typ -- 12 1024 TOSC 96 -- 200 * 100 * Max -- 25 * Units ns ms ms ms ns TOSC = OSC1 period Conditions
TmcL2adI MCLR to System Interface bus (AD15:AD0) invalid
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. This specification ensured by design.
(c) 1996 Microchip Technology Inc.
DS30412C-page 157
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-5: TIMER0 CLOCK TIMINGS
RA1/T0CKI
40
41
42
TABLE 17-5:
Parameter No. 40 41 42
TIMER0 CLOCK REQUIREMENTS
Min No Prescaler With Prescaler No Prescaler With Prescaler 0.5TCY + 20 10* 0.5TCY + 20 10* TCY + 40 N Typ Max Units Conditions -- -- -- -- -- -- -- -- -- -- ns ns ns ns ns
Sym Characteristic Tt0H T0CKI High Pulse Width Tt0L T0CKI Low Pulse Width Tt0P T0CKI Period
N = prescale value (1, 2, 4, ..., 256)
*

These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
FIGURE 17-6: TIMER1, TIMER2, AND TIMER3 CLOCK TIMINGS
TCLK12 or TCLK3 45 46
47 48 TMRx
48
TABLE 17-6:
Parameter No. 45 46 47 48 *
TIMER1, TIMER2, AND TIMER3 CLOCK REQUIREMENTS
Characteristic TCLK12 and TCLK3 high time TCLK12 and TCLK3 low time TCLK12 and TCLK3 input period Min 0.5 TCY + 20 0.5 TCY + 20 TCY + 40 N 2TOSC Typ -- -- -- Max -- -- -- Units Conditions ns ns ns
Sym Tt123H Tt123L Tt123P
N = prescale value (1, 2, 4, 8)
TckE2tmrI Delay from selected External Clock Edge to -- 6 Tosc -- Timer increment These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
DS30412C-page 158
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-7: CAPTURE TIMINGS
CAP1 and CAP2 (Capture Mode)
50 52
51
TABLE 17-7:
Parameter No. 50 51 52 *
CAPTURE REQUIREMENTS
Min 10 * 10 * 2 TCY N Typ Max Units Conditions -- -- -- -- -- -- ns ns ns N = prescale value (4 or 16)
Sym Characteristic TccL Capture1 and Capture2 input low time TccH Capture1 and Capture2 input high time TccP Capture1 and Capture2 input period
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
FIGURE 17-8: PWM TIMINGS
PWM1 and PWM2 (PWM Mode) 53 54
TABLE 17-8:
Parameter No. 53 54
PWM REQUIREMENTS
Min -- -- Typ Max Units Conditions 10 * 35 * 10 * 35 * ns ns
Sym Characteristic TccR PWM1 and PWM2 output rise time TccF PWM1 and PWM2 output fall time
*

These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
(c) 1996 Microchip Technology Inc.
DS30412C-page 159
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-9: USART MODULE: SYNCHRONOUS TRANSMISSION (MASTER/SLAVE) TIMING
RA5/TX/CK pin RA4/RX/DT pin
121
121
120
122
TABLE 17-9:
Parameter No. 120 121 122
SERIAL PORT SYNCHRONOUS TRANSMISSION REQUIREMENTS
Sym TckH2dtV TckRF TdtRF Characteristic SYNC XMIT (MASTER & SLAVE) Clock high to data out valid Clock out rise time and fall time (Master Mode) Data out rise time and fall time Min -- -- -- Typ -- 10 10 Max 65 35 35 Units Conditions ns ns ns
Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested.
FIGURE 17-10: USART MODULE: SYNCHRONOUS RECEIVE (MASTER/SLAVE) TIMING
RA5/TX/CK pin RA4/RX/DT pin
125
126
TABLE 17-10: SERIAL PORT SYNCHRONOUS RECEIVE REQUIREMENTS
Parameter No. 125 126 Sym TdtV2ckL TckL2dtl Characteristic SYNC RCV (MASTER & SLAVE) Data hold before CK (DT hold time) Data hold after CK (DT hold time) Min 15 15 Typ -- -- Max -- -- Units Conditions ns ns
Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested.
DS30412C-page 160
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-11: MEMORY INTERFACE WRITE TIMING
Q1 Q2 Q3 Q4 Q1 Q2
OSC1
ALE
OE WR 150 AD<15:0> addr out
151
154 data out 152 153 addr out
TABLE 17-11: MEMORY INTERFACE WRITE REQUIREMENTS
Parameter No. 150 151 152 153 154 * Sym TadV2alL TalL2adI TadV2wrL TwrH2adI TwrL Characteristic AD<15:0> (address) valid to ALE (address setup time) ALE to address out invalid (address hold time) Data out valid to WR (data setup time) WR to data out invalid (data hold time) WR pulse width Min 0.25Tcy - 30 0 0.25Tcy - 40 -- -- Typ -- -- -- 0.25TCY 0.25TCY Max -- -- -- -- -- Units Conditions ns ns ns ns ns
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification is guaranteed by design.
(c) 1996 Microchip Technology Inc.
DS30412C-page 161
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 17-12: MEMORY INTERFACE READ TIMING
Q1 Q2 Q3 Q4 Q1 Q2
OSC1 166 ALE OE 164 168 160 165 AD<15:0> 150 151 WR '1' 167 Addr out 162 163 '1' Data in 161 Addr out
TABLE 17-12: MEMORY INTERFACE READ REQUIREMENTS
Parameter No. 150 151 160 161 162 163 164 165 166 167 168 * Sym TadV2alL TalL2adI TadZ2oeL ToeH2adD TadV2oeH ToeH2adI TalH ToeL TalH2alH Tacc Toe Characteristic AD<15:0> (address) valid to ALE (address setup time) ALE to address out invalid (address hold time) AD<15:0> high impedance to OE OE to AD<15:0> driven Data in valid before OE (data setup time) OEto data in invalid (data hold time) ALE pulse width OE pulse width ALE to ALE (cycle time) Address access time Output enable access time (OE low to Data Valid) Min 0.25Tcy - 30 5* 0* 0.25Tcy - 15 35 0 -- 0.5Tcy - 35 -- -- -- Typ -- -- -- -- -- -- 0.25TCY -- TCY -- -- Max -- -- -- -- -- -- -- -- -- 0.75 TCY-40 0.5 TCY - 60 Units Conditions ns ns ns ns ns ns ns ns ns ns ns
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification guaranteed by design.
DS30412C-page 162
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
18.0
PIC17C42 DC AND AC CHARACTERISTICS
The graphs and tables provided in this section are for design guidance and are not tested or guaranteed. In some graphs or tables the data presented are outside specified operating range (e.g. outside specified VDD range). This is for information only and devices are ensured to operate properly only within the specified range. The data presented in this section is a statistical summary of data collected on units from different lots over a period of time. "Typical" represents the mean of the distribution while "max" or "min" represents (mean + 3 ) and (mean - 3) respectively where is standard deviation.
TABLE 18-1:
Pin Name
PIN CAPACITANCE PER PACKAGE TYPE
Typical Capacitance (pF) 40-pin DIP 44-pin PLCC 10 20 44-pin MQFP 10 20 44-pin TQFP 10 20
All pins, except MCLR, VDD, and VSS MCLR pin
10 20
FIGURE 18-1: TYPICAL RC OSCILLATOR FREQUENCY vs. TEMPERATURE
FOSC FOSC (25C) 1.10 1.08 1.06 1.04 1.02 1.00 VDD = 5.5V 0.98 0.96 0.94 VDD = 3.5V 0.92 0.90 0 10 20 25 30 T(C) 40 50 60 70 Rext 10 k Cext = 100 pF Frequency normalized to +25C
(c) 1996 Microchip Technology Inc.
DS30412C-page 163
This document was created with FrameMaker 4 0 4
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-2: TYPICAL RC OSCILLATOR FREQUENCY vs. VDD
4.0 3.5 3.0 FOSC (MHz) 2.5 2.0 1.5 Cext = 22 pF, T = 25C 1.0 0.5 0.0 4.0 4.5 5.0 VDD (Volts) R = 100k 5.5 6.0 6.5 R = 10k
FIGURE 18-3: TYPICAL RC OSCILLATOR FREQUENCY vs. VDD
4.0 3.5 3.0 FOSC (MHz) 2.5 2.0 1.5 1.0 Cext = 100 pF, T = 25C 0.5 0.0 4.0 4.5 5.0 VDD (Volts) 5.5 6.0 6.5 R = 100k R = 10k R = 5.1k R = 3.3k
DS30412C-page 164
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-4: TYPICAL RC OSCILLATOR FREQUENCY vs. VDD
2.0 1.8 1.6 1.4 1.2 FOSC (MHz) R = 5.1k 1.0 0.8 0.6 0.4 Cext = 300 pF, T = 25C 0.2 0.0 4.0 4.5 5.0 VDD (Volts) R = 160k 5.5 6.0 6.5 R = 10k R = 3.3k
TABLE 18-2:
Cext 22 pF
RC OSCILLATOR FREQUENCIES
Rext 10k 100k 3.3k 5.1k 10k 100k 3.3k 5.1k 10k 160k 3.33 MHz 353 kHz 3.54 MHz 2.43 MHz 1.30 MHz 129 kHz 1.54 MHz 980 kHz 564 kHz 35 kHz Average Fosc @ 5V, 25C 12% 13% 10% 14% 17% 10% 14% 12% 16% 18%
100 pF
300 pF
(c) 1996 Microchip Technology Inc.
DS30412C-page 165
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-5: TRANSCONDUCTANCE (gm) OF LF OSCILLATOR vs. VDD
500 450 400 350 Max @ -40C 300 gm(A/V) Typ @ 25C 250 200 150 Min @ 85C 100 50 0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0
FIGURE 18-6: TRANSCONDUCTANCE (gm) OF XT OSCILLATOR vs. VDD
20 18 Max @ -40C 16 14 Typ @ 25C 12 gm(mA/V) 10 8 6 Min @ 85C 4 2 0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0
DS30412C-page 166
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-7: TYPICAL IDD vs. FREQUENCY (EXTERNAL CLOCK 25C)
100000
10000
IDD (A)
1000 7.0V 6.5V 6.0V 5.5V 5.0V 4.5V 4.0V
100
10 10k
100k
1M External Clock Frequency (Hz)
10M
100M
FIGURE 18-8: MAXIMUM IDD vs. FREQUENCY (EXTERNAL CLOCK 125C TO -40C)
100000
10000
IDD (A)
1000
7.0V 6.5V 6.0V 5.5V 5.0V 4.5V 4.0V
100 10k 100k 1M External Clock Frequency (Hz) 10M 100M
(c) 1996 Microchip Technology Inc.
DS30412C-page 167
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-9: TYPICAL IPD vs. VDD WATCHDOG DISABLED 25C
12
10
8 IPD(nA)
6
4
2
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
FIGURE 18-10: MAXIMUM IPD vs. VDD WATCHDOG DISABLED
1900 1800 1700 1600 1500 1400 1300 1200 1100 1000 900 800 700 600 500 400 300 200 100 0 4.0
IPD(nA)
Temp. = 85C
Temp. = 70C Temp. = 0C Temp. = -40C 6.5 7.0
4.5
5.0
5.5 VDD (Volts)
6.0
DS30412C-page 168
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-11: TYPICAL IPD vs. VDD WATCHDOG ENABLED 25C
30
25
20 IPD(A)
15
10
5
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
FIGURE 18-12: MAXIMUM IPD vs. VDD WATCHDOG ENABLED
60
50 -40C 40 IPD(A) 70C 0C 85C 30
20
10
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
(c) 1996 Microchip Technology Inc.
DS30412C-page 169
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-13: WDT TIMER TIME-OUT PERIOD vs. VDD
30
25 Max. 85C 20 WDT Period (ms) Max. 70C 15 Min. 0C Typ. 25C
10 Min. -40C 5
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
FIGURE 18-14: IOH vs. VOH, VDD = 3V
0 -2 -4 IOH(mA) -6 -8 -10 -12 -14 -16 -18 0.0 0.5 1.0 1.5 VDD (Volts) 2.0 2.5 3.0 Max @ -40C Typ @ 25C Min @ 85C
DS30412C-page 170
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-15: IOH vs. VOH, VDD = 5V
0 IOH(mA) -5 -10 Min @ 85C -15 -20 Max @ -40C -25 -30 -35 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 Typ @ 25C
VDD (Volts)
FIGURE 18-16: IOL vs. VOL, VDD = 3V
30 Max. -40C 25 Typ. 25C 20 IOL(mA)
15 Min. +85C 10
5
0 0.0 0.5 1.0 1.5 VDD (Volts) 2.0 2.5 3.0
(c) 1996 Microchip Technology Inc.
DS30412C-page 171
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-17: IOL vs. VOL, VDD = 5V
90 80 70 Max @ -40C IOH(mA) 60 50 40 30 20 10 0 0.0 0.5 1.0 1.5 VDD (Volts) 2.0 2.5 3.0 Min @ +85C Typ @ 25C
FIGURE 18-18: VTH (INPUT THRESHOLD VOLTAGE) OF I/O PINS (TTL) VS. VDD
2.0 1.8 Max (-40C to +85C) 1.6 Typ @ 25C VTH(Volts) 1.4 1.2 1.0 Min (-40C to +85C) 0.8 0.6 2.5
3.0
3.5
4.0 VDD (Volts)
4.5
5.0
5.5
6.0
DS30412C-page 172
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 18-19: VTH, VIL of I/O PINS (SCHMITT TRIGGER) VS. VDD
5.0 VIH, max (-40C to +85C) 4.5 VIH, typ (25C) 4.0 VIH, min (-40C to +85C) 3.5 VIH, VIL(Volts) 3.0 2.5 2.0 1.5 1.0 0.5 0.0 2.0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0 VIL, max (-40C to +85C) VIL, typ (25C) VIL, min (-40C to +85C)
FIGURE 18-20: VTH (INPUT THRESHOLD VOLTAGE) OF OSC1 INPUT (IN XT AND LF MODES) vs. VDD
3.4 3.2 3.0 Max (-40C to +85C) 2.8 VTH,(Volts) 2.6 2.4 2.2 2.0 Min (-40C to +85C) 1.8 1.6 1.4 1.2 1.0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0 Typ (25C)
(c) 1996 Microchip Technology Inc.
DS30412C-page 173
PIC17C4X
NOTES:
DS30412C-page 174
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
19.0
PIC17CR42/42A/43/R43/44 ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings Ambient temperature under bias..................................................................................................................-55 to +125C Storage temperature ............................................................................................................................... -65C to +150C Voltage on VDD with respect to VSS ................................................................................................................ 0 to +7.5V Voltage on MCLR with respect to VSS (Note 2) ..........................................................................................-0.6V to +14V Voltage on RA2 and RA3 with respect to VSS..............................................................................................-0.6V to +14V Voltage on all other pins with respect to VSS ..................................................................................... -0.6V to VDD + 0.6V Total power dissipation (Note 1).................................................................................................................................1.0W Maximum current out of VSS pin(s) - total ..............................................................................................................250 mA Maximum current into VDD pin(s) - total .................................................................................................................200 mA Input clamp current, IIK (VI < 0 or VI > VDD) ......................................................................................................................20 mA Output clamp current, IOK (VO < 0 or VO > VDD) ...............................................................................................................20 mA Maximum output current sunk by any I/O pin (except RA2 and RA3)......................................................................35 mA Maximum output current sunk by RA2 or RA3 pins .................................................................................................60 mA Maximum output current sourced by any I/O pin .....................................................................................................20 mA Maximum current sunk by PORTA and PORTB (combined)..................................................................................150 mA Maximum current sourced by PORTA and PORTB (combined).............................................................................100 mA Maximum current sunk by PORTC, PORTD and PORTE (combined)...................................................................150 mA Maximum current sourced by PORTC, PORTD and PORTE (combined)..............................................................100 mA Note 1: Power dissipation is calculated as follows: Pdis = VDD x {IDD - IOH} + {(VDD-VOH) x IOH} + (VOL x IOL) Note 2: Voltage spikes below VSS at the MCLR pin, inducing currents greater than 80 mA, may cause latch-up. Thus, a series resistor of 50-100 should be used when applying a "low" level to the MCLR pin rather than pulling this pin directly to VSS. NOTICE: Stresses above those listed under "Absolute Maximum Ratings" may cause permanent damage to the device. This is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. Exposure to maximum rating conditions for extended periods may affect device reliability.
(c) 1996 Microchip Technology Inc.
DS30412C-page 175
This document was created with FrameMaker 4 0 4
TABLE 19-1:
DS30412C-page 176
PIC17C4X
OSC
PIC17LCR42-08 PIC17LC42A-08 PIC17LC43-08 PIC17LCR43-08 PIC17LC44-08
PIC17CR42-16 PIC17C42A-16 PIC17C43-16 PIC17CR43-16 PIC17C44-16
PIC17CR42-25 PIC17C42A-25 PIC17C43-25 PIC17CR43-25 PIC17C44-25
PIC17CR42-33 PIC17C42A-33 PIC17C43-33 PIC17CR43-33 PIC17C44-33
JW Devices (Ceramic Windowed Devices)
Applicable Devices 42 R42 42A 43 R43 44
CROSS REFERENCE OF DEVICE SPECS FOR OSCILLATOR CONFIGURATIONS AND FREQUENCIES OF OPERATION (COMMERCIAL DEVICES)
VDD: 2.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V IDD: 6 mA max. IDD: 6 mA max. IDD: 6 mA max. IDD: 6 mA max. IDD: 6 mA max. IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V WDT disabled WDT disabled WDT disabled WDT disabled WDT disabled Freq: 4 MHz max. Freq: 4 MHz max. Freq: 4 MHz max. Freq: 4 MHz max. Freq: 4 MHz max. XT VDD: 2.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V IDD: 12 mA max. IDD: 24 mA max. IDD: 38 mA max. IDD: 38 mA max. IDD: 38 mA max. IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V WDT disabled WDT disabled WDT disabled WDT disabled WDT disabled Freq: 8 MHz max. Freq: 16 MHz max. Freq: 25 MHz max. Freq: 33 MHz max. Freq: 33 MHz max. EC VDD: 2.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V IDD: 12 mA max. IDD: 24 mA max. IDD: 38 mA max. IDD: 38 mA max. IDD: 38 mA max. IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V IPD: 5 A max. at 5.5V WDT disabled WDT disabled WDT disabled WDT disabled WDT disabled Freq: 8 MHz max. Freq: 16 MHz Max Freq: 25 MHz max. Freq: 33 MHz max. Freq: 33 MHz max. LF VDD: 2.5V to 6.0V VDD: 2.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V VDD: 4.5V to 6.0V IDD: 150 A max. at 32 kHz IDD: 95 A typ. at 32 kHz IDD: 95 A typ. at 32 kHz IDD: 95 A typ. at 32 kHz IDD: 150 A max. at 32 kHz IPD: 5 A max. at 5.5V IPD: < 1 A typ. at 5.5V IPD: < 1 A typ. at 5.5V IPD: < 1 A typ. at 5.5V IPD: 5 A max. at 5.5V WDT disabled WDT disabled WDT disabled WDT disabled WDT disabled Freq: 2 MHz max. Freq: 2 MHz max. Freq: 2 MHz max. Freq: 2 MHz max. Freq: 2 MHz max. The shaded sections indicate oscillator selections which are tested for functionality, but not for MIN/MAX specifications. It is recommended that the user select the device type that ensures the specifications required.
RC
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 19.1 DC CHARACTERISTICS: PIC17CR42/42A/43/R43/44-16 (Commercial, Industrial) PIC17CR42/42A/43/R43/44-25 (Commercial, Industrial) PIC17CR42/42A/43/R43/44-33 (Commercial, Industrial)
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +85C for industrial and 0C TA +70C for commercial
DC CHARACTERISTICS Parameter No. D001 D002 D003
Sym VDD VDR VPOR
D004
SVDD
D010 D011 D012 D013 D015 D014
IDD
Characteristic Min Typ Max Units Conditions Supply Voltage 4.5 - 6.0 V RAM Data Retention 1.5 * - - V Device in SLEEP mode Voltage (Note 1) VDD start voltage to - VSS - V See section on Power-on Reset for ensure internal details Power-on Reset signal VDD rise rate to 0.060 * - - mV/ms See section on Power-on Reset for ensure internal details Power-on Reset signal FOSC = 4 MHz (Note 4) mA 6 3 Supply Current - mA 12 * 6 (Note 2) - FOSC = 8 MHz mA 24 * 11 - FOSC = 16 MHz mA 38 19 - FOSC = 25 MHz mA 50 25 - FOSC = 33 MHz A 150 95 - FOSC = 32 kHz, WDT enabled (EC osc configuration)
Power-down - 10 40 A VDD = 5.5V, WDT enabled D020 IPD Current (Note 3) - <1 5 A VDD = 5.5V, WDT disabled D021 * These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. Note 1: This is the limit to which VDD can be lowered in SLEEP mode without losing RAM data. 2: The supply current is mainly a function of the operating voltage and frequency. Other factors such as I/O pin loading and switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current consumption. The test conditions for all IDD measurements in active operation mode are: OSC1 = external square wave, from rail to rail; all I/O pins tristated, pulled to VDD or VSS, T0CKI = VDD, MCLR = VDD; WDT enabled/disabled as specified. Current consumed from the oscillator and I/O's driving external capacitive or resistive loads needs to be considered. For the RC oscillator, the current through the external pull-up resistor (R) can be estimated as: VDD / (2 * R). For capacitive loads, the current can be estimated (for an individual I/O pin) as (CL * VDD) * f CL = Total capacitive load on the I/O pin; f = average frequency the I/O pin switches. The capacitive currents are most significant when the device is configured for external execution (includes extended microcontroller mode). 3: The power down current in SLEEP mode does not depend on the oscillator type. Power-down current is measured with the part in SLEEP mode, with all I/O pins in hi-impedance state and tied to VDD and VSS. 4: For RC osc configuration, current through Rext is not included. The current through the resistor can be estimated by the formula IR = VDD/2Rext (mA) with Rext in kOhm.
(c) 1996 Microchip Technology Inc.
DS30412C-page 177
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 19.2 DC CHARACTERISTICS: PIC17LC42A/43/LC44 (Commercial, Industrial) PIC17LCR42/43 (Commercial, Industrial)
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +85C for industrial and 0C TA +70C for commercial Min Typ Max - - VSS 6.0 - - Units V V V Conditions Device in SLEEP mode See section on Power-on Reset for details
DC CHARACTERISTICS Parameter No. D001 D002 D003
Sym VDD VDR VPOR
Characteristic
D004
SVDD
D010 D011 D014
IDD
Supply Voltage 2.5 RAM Data Retention 1.5 * Voltage (Note 1) VDD start voltage to - ensure internal Power-on Reset signal VDD rise rate to 0.060 * ensure internal Power-on Reset signal Supply Current - (Note 2) - -
-
-
mV/ms See section on Power-on Reset for details mA mA A FOSC = 4 MHz (Note 4) FOSC = 8 MHz FOSC = 32 kHz, WDT disabled (EC osc configuration) VDD = 5.5V, WDT enabled VDD = 5.5V, WDT disabled
3 6 95
6 12 * 150
D020 IPD Power-down - 10 40 A D021 Current (Note 3) - <1 5 A * These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. Note 1: This is the limit to which VDD can be lowered in SLEEP mode without losing RAM data. 2: The supply current is mainly a function of the operating voltage and frequency. Other factors such as I/O pin loading and switching rate, oscillator type, internal code execution pattern, and temperature also have an impact on the current consumption. The test conditions for all IDD measurements in active operation mode are: OSC1=external square wave, from rail to rail; all I/O pins tristated, pulled to VDD or VSS, T0CKI = VDD, MCLR = VDD; WDT enabled/disabled as specified. Current consumed from the oscillator and I/O's driving external capacitive or resistive loads needs to be considered. For the RC oscillator, the current through the external pull-up resistor (R) can be estimated as: VDD / (2 * R). For capacitive loads, the current can be estimated (for an individual I/O pin) as (CL * VDD) * f CL = Total capacitive load on the I/O pin; f = average frequency the I/O pin switches. The capacitive currents are most significant when the device is configured for external execution (includes extended microcontroller mode). 3: The power down current in SLEEP mode does not depend on the oscillator type. Power-down current is measured with the part in SLEEP mode, with all I/O pins in hi-impedance state and tied to VDD or VSS. 4: For RC osc configuration, current through Rext is not included. The current through the resistor can be estimated by the formula IR = VDD/2Rext (mA) with Rext in kOhm.
DS30412C-page 178
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 19.3 DC CHARACTERISTICS: PIC17CR42/42A/43/R43/44-16 (Commercial, Industrial) PIC17CR42/42A/43/R43/44-25 (Commercial, Industrial) PIC17CR42/42A/43/R43/44-33 (Commercial, Industrial) PIC17LCR42/42A/43/R43/44-08 (Commercial, Industrial)
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +85C for industrial and 0C TA +70C for commercial Operating voltage VDD range as described in Section 19.1 Characteristic Input Low Voltage I/O ports with TTL buffer with Schmitt Trigger buffer MCLR, OSC1 (in EC and RC mode) OSC1 (in XT, and LF mode) Input High Voltage I/O ports with TTL buffer Min Typ Max Units Conditions
DC CHARACTERISTICS
Parameter No. Sym VIL D030 D031 D032 D033 VIH D040 D041 D042 D043 D050
VSS VSS VSS Vss -
- - - - 0.5VDD
0.8 0.2VDD 0.2VDD 0.2VDD -
V V V V V
4.5V VDD 5.5V 2.5V VDD 4.5V Note1
2.0 1 + 0.2VDD with Schmitt Trigger buffer 0.8VDD
- - -
VDD VDD VDD VDD - -
V V V V V V
4.5V VDD 5.5V 2.5V VDD 4.5V Note1
D060
MCLR OSC1 (XT, and LF mode) VHYS Hysteresis of Schmitt Trigger inputs Input Leakage Current (Notes 2, 3) IIL I/O ports (except RA2, RA3)
0.8VDD - - 0.5VDD 0.15VDD * -
-
-
1
A Vss VPIN VDD, I/O Pin at hi-impedance PORTB weak pull-ups disabled A A A A VPIN = Vss or VPIN = VDD Vss VRA2, VRA3 12V Vss VPIN VDD RF 1 M, see Figure 14.2
D061 D062 D063 D063B D064 D070 * Note 1:
2: 3: 4:
MCLR RA2, RA3 OSC1, TEST (EC, RC modes) OSC1, TEST (XT, LF modes) MCLR IPURB PORTB weak pull-up current
- - - - 60
- - - - 200
2 2 1 VPIN 10 400
A VMCLR = VPP = 12V (when not programming) A VPIN = VSS, RBPU = 0 4.5V VDD 6.0V
5: 6:
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that the PIC17CXX devices be driven with external clock in RC mode. The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. Negative current is defined as coming out of the pin. These specifications are for the programming of the on-chip program memory EPROM through the use of the table write instructions. The complete programming specifications can be found in: PIC17CXX Programming Specifications (Literature number DS30139). The MCLR/VPP pin may be kept in this range at times other than programming, but is not recommended. For TTL buffers, the better of the two specifications may be used.
(c) 1996 Microchip Technology Inc.
DS30412C-page 179
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +85C for industrial and 0C TA +70C for commercial Operating voltage VDD range as described in Section 19.1 Characteristic Output Low Voltage I/O ports (except RA2 and RA3) - - - - - - - - - - - - 0.1VDD 0.1VDD * 0.4 3.0 0.4 0.1VDD * V V V V V V Min Typ Max Units Conditions IOL = VDD/1.250 mA 4.5V VDD 6.0V VDD = 2.5V IOL = 6 mA, VDD = 4.5V Note 6 IOL = 60.0 mA, VDD = 6.0V IOL = 1 mA, VDD = 4.5V IOL = VDD/5 mA (PIC17LC43/LC44 only) IOH = -VDD/2.500 mA 4.5V VDD 6.0V VDD = 2.5V IOH = -6.0 mA, VDD=4.5V Note 6 Pulled-up to externally applied voltage IOH = -5 mA, VDD = 4.5V IOH = -VDD/5 mA (PIC17LC43/LC44 only)
DC CHARACTERISTICS
Parameter No. Sym D080 VOL
D081 D082 D083 D084
with TTL buffer RA2 and RA3 OSC2/CLKOUT (RC and EC osc modes) Output High Voltage (Note 3) I/O ports (except RA2 and RA3)
D090
VOH
D091 D092 D093 D094
with TTL buffer RA2 and RA3 OSC2/CLKOUT (RC and EC osc modes) Capacitive Loading Specs on Output Pins COSC2 OSC2/CLKOUT pin
0.9VDD 0.9VDD * 2.4 - 2.4 0.9VDD *
- - - - - -
- - - 12 - -
V V V V V V
D100
-
-
25
D101 D102
CIO CAD
All I/O pins and OSC2 (in RC mode) System Interface Bus (PORTC, PORTD and PORTE)
- -
- -
50 50
pF In EC or RC osc modes when OSC2 pin is outputting CLKOUT. external clock is used to drive OSC1. pF pF In Microprocessor or Extended Microcontroller mode
* Note 1:
2: 3: 4:
5: 6:
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that the PIC17CXX devices be driven with external clock in RC mode. The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. Negative current is defined as coming out of the pin. These specifications are for the programming of the on-chip program memory EPROM through the use of the table write instructions. The complete programming specifications can be found in: PIC17CXX Programming Specifications (Literature number DS30139). The MCLR/VPP pin may be kept in this range at times other than programming, but is not recommended. For TTL buffers, the better of the two specifications may be used.
DS30412C-page 180
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
Standard Operating Conditions (unless otherwise stated) Operating temperature -40C TA +40C Operating voltage VDD range as described in Section 19.1 Characteristic Internal Program Memory Programming Specs (Note 4) D110 D111 D112 D113 D114 * Note 1: 2: VPP Voltage on MCLR/VPP pin VDDP Supply voltage during programming Current into MCLR/VPP pin IPP IDDP Supply current during programming TPROG Programming pulse width 12.75 4.75 - - 10 - 5.0 25 - 100 13.25 5.25 50 30 1000 V V mA mA s Terminated via internal/ external interrupt or a reset Note 5 Min Typ Max Units Conditions
DC CHARACTERISTICS Parameter No. Sym
3: 4:
5: 6:
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. In RC oscillator configuration, the OSC1/CLKIN pin is a Schmitt Trigger input. It is not recommended that the PIC17CXX devices be driven with external clock in RC mode. The leakage current on the MCLR pin is strongly dependent on the applied voltage level. The specified levels represent normal operating conditions. Higher leakage current may be measured at different input voltages. Negative current is defined as coming out of the pin. These specifications are for the programming of the on-chip program memory EPROM through the use of the table write instructions. The complete programming specifications can be found in: PIC17CXX Programming Specifications (Literature number DS30139). The MCLR/VPP pin may be kept in this range at times other than programming, but is not recommended. For TTL buffers, the better of the two specifications may be used.
Note:
When using the Table Write for internal programming, the device temperature must be less than 40C.
(c) 1996 Microchip Technology Inc.
DS30412C-page 181
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 19.4 Timing Parameter Symbology
The timing parameter symbols have been created following one of the following formats: 1. TppS2ppS 2. TppS T F Frequency Lowercase symbols (pp) and their meanings: pp ad Address/Data al ALE cc Capture1 and Capture2 ck CLKOUT or clock dt Data in in INT pin io I/O port mc MCLR oe OE os OSC1 Uppercase symbols and their meanings: S D Driven E Edge F Fall H High I Invalid (Hi-impedance) T Time 3. TCC:ST 4. Ts (I2C specifications only) (I2C specifications only)
ost pwrt rb rd rw t0 t123 wdt wr
Oscillator Start-Up Timer Power-Up Timer PORTB RD RD or WR T0CKI TCLK12 and TCLK3 Watchdog Timer WR
L P R V Z
Low Period Rise Valid Hi-impedance
DS30412C-page 182
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-1: PARAMETER MEASUREMENT INFORMATION
All timings are measure between high and low measurement points as indicated in the figures below.
INPUT LEVEL CONDITIONS
PORTC, D and E pins VIH = 2.4V VIL = 0.4V Data in valid All other input pins Data in invalid VIH = 0.9VDD VIL = 0.1VDD Data in valid Data in invalid
OUTPUT LEVEL CONDITIONS
0.25V VOH = 0.7VDD VDD/2 VOL = 0.3VDD Data out valid Data out invalid 0.25V 0.25V 0.25V Output driven Output hi-impedance 0.9 VDD 0.1 VDD Rise Time Fall Time
LOAD CONDITIONS
Load Condition 1
Pin
CL
VSS
50 pF CL
(c) 1996 Microchip Technology Inc.
DS30412C-page 183
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 19.5 Timing Diagrams and Specifications
FIGURE 19-2: EXTERNAL CLOCK TIMING
Q4 OSC1 1 2 OSC2 In EC and RC modes only. 3 3 4 Q1 Q2 Q3 Q4 Q1
4
TABLE 19-2:
Param No. Sym
EXTERNAL CLOCK TIMING REQUIREMENTS
Characteristic Min Typ Max Units Conditions
1
2 3 4 Note
-- 8 MHz EC osc mode - 08 devices (8 MHz devices) Fosc External CLKIN Frequency DC DC -- 16 MHz - 16 devices (16 MHz devices) (Note 1) DC -- 25 MHz - 25 devices (25 MHz devices) DC -- 33 MHz - 33 devices (33 MHz devices) Oscillator Frequency DC -- 4 MHz RC osc mode (Note 1) 1 -- 8 MHz XT osc mode - 08 devices (8 MHz devices) 1 -- 16 MHz - 16 devices (16 MHz devices) 1 -- 25 MHz - 25 devices (25 MHz devices) 1 -- 33 MHz - 33 devices (33 MHz devices) DC -- 2 MHz LF osc mode Tosc External CLKIN Period 125 -- -- ns EC osc mode - 08 devices (8 MHz devices) (Note 1) 62.5 -- -- ns - 16 devices (16 MHz devices) 40 -- -- ns - 25 devices (25 MHz devices) 30.3 -- -- ns - 33 devices (33 MHz devices) Oscillator Period 250 -- -- ns RC osc mode (Note 1) 125 -- 1,000 ns XT osc mode - 08 devices (8 MHz devices) 62.5 -- 1,000 ns - 16 devices (16 MHz devices) 40 -- 1,000 ns - 25 devices (25 MHz devices) 30.3 -- 1,000 ns - 33 devices (33 MHz devices) 500 -- -- ns LF osc mode 121.2 4/Fosc DC ns TCY Instruction Cycle Time (Note 1) TosL, Clock in (OSC1) 10 -- -- ns EC oscillator TosH high or low time TosR, Clock in (OSC1) -- -- 5 ns EC oscillator TosF rise or fall time Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. 1: Instruction cycle period (TCY) equals four times the input oscillator time base period. All specified values are based on characterization data for that particular oscillator type under standard operating conditions with the device executing code. Exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. All devices are tested to operate at "min." values with an external clock applied to the OSC1/CLKIN pin. When an external clock input is used, the "max." cycle time limit is "DC" (no clock) for all devices.
DS30412C-page 184
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-3: CLKOUT AND I/O TIMING
Q4 OSC1 10 OSC2 13 14 I/O Pin (input) 17 I/O Pin (output) old value 20, 21 In EC and RC modes only. 15 new value 18 19 22 23 12 16 11 Q1 Q2 Q3
TABLE 19-3:
Parameter No. Sym 10 11 12 13 14
CLKOUT AND I/O TIMING REQUIREMENTS
Characteristic OSC1 to CLKOUT OSC1 to CLKOUT CLKOUT rise time CLKOUT fall time CLKOUT to Port PIC17CR42/42A/43/ out valid R43/44 PIC17LCR42/42A/43/ R43/44 Min -- -- -- -- -- -- 0.25TCY + 25 0.25TCY + 50 0 -- 0 30 -- -- 25 * 25 * Typ 15 15 5 5 -- -- -- -- -- -- -- -- 10 10 -- -- Max 30 30 15 15 0.5TCY + 20 0.5TCY + 50 -- -- -- 100 -- -- 35 35 -- -- Units Conditions ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns ns Note 1 Note 1 Note 1 Note 1 Note 1 Note 1 Note 1 Note 1 Note 1
TosH2ckL TosH2ckH TckR TckF TckH2ioV
15
TioV2ckH
Port in valid before PIC17CR42/42A/43/ CLKOUT R43/44 PIC17LCR42/42A/43/ R43/44
16 17 18 19 20 21 22 23 *
TckH2ioI TosH2ioV TosH2ioI TioV2osH TioR TioF TinHL TrbHL
Port in hold after CLKOUT OSC1 (Q1 cycle) to Port out valid OSC1 (Q2 cycle) to Port input invalid (I/O in hold time) Port input valid to OSC1 (I/O in setup time) Port output rise time Port output fall time INT pin high or low time RB7:RB0 change INT high or low time
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. Note 1: Measurements are taken in EC Mode where CLKOUT output is 4 x TOSC.
(c) 1996 Microchip Technology Inc.
DS30412C-page 185
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-4: RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER, AND POWER-UP TIMER TIMING
VDD MCLR 30 Internal POR 33 PWRT Timeout OSC Timeout Internal RESET Watchdog Timer RESET 35 Address / Data 32
31
TABLE 19-4:
Parameter No. 30 31 32 33 35
RESET, WATCHDOG TIMER, OSCILLATOR START-UP TIMER AND POWER-UP TIMER REQUIREMENTS
Sym TmcL Twdt Tost Tpwrt Characteristic MCLR Pulse Width (low) Watchdog Timer Time-out Period (Prescale = 1) Oscillation Start-up Timer Period Power-up Timer Period PIC17CR42/42A/ 43/R43/44 PIC17LCR42/ 42A/43/R43/44 Min 100 * 5* -- 40 * -- -- Typ -- 12 1024TOSC 96 -- -- Max -- 25 * -- 200 * 100 * 120 * Units ns ms ms ms ns ns Conditions
VDD = 5V VDD = 5V
TOSC = OSC1 period
VDD = 5V
TmcL2adI MCLR to System Interface bus (AD15:AD0>) invalid
*
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. These parameters are for design guidance only and are not tested, nor characterized. This specification ensured by design.
DS30412C-page 186
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-5: TIMER0 CLOCK TIMINGS
RA1/T0CKI
40
41
42
TABLE 19-5:
Parameter No. 40 41 42
TIMER0 CLOCK REQUIREMENTS
Min No Prescaler With Prescaler No Prescaler With Prescaler 0.5TCY + 20 10* 0.5TCY + 20 10* Greater of: 20 ns or Tcy + 40 N Typ Max Units Conditions -- -- -- -- -- -- -- -- -- -- ns ns ns ns ns
Sym Characteristic Tt0H T0CKI High Pulse Width Tt0L T0CKI Low Pulse Width Tt0P T0CKI Period
N = prescale value (1, 2, 4, ..., 256)
*
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
FIGURE 19-6: TIMER1, TIMER2, AND TIMER3 CLOCK TIMINGS
TCLK12 or TCLK3 45 46
47 48 TMRx
48
TABLE 19-6:
Parameter No. 45 46 47 48 *
TIMER1, TIMER2, AND TIMER3 CLOCK REQUIREMENTS
Characteristic Min 0.5TCY + 20 0.5TCY + 20 TCY + 40 N 2TOSC Typ -- -- -- Max -- -- -- Units Conditions ns ns ns
Sym
Tt123H TCLK12 and TCLK3 high time Tt123L TCLK12 and TCLK3 low time Tt123P TCLK12 and TCLK3 input period
N = prescale value (1, 2, 4, 8)
TckE2tmrI Delay from selected External Clock Edge to 6Tosc Timer increment These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
(c) 1996 Microchip Technology Inc.
DS30412C-page 187
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-7: CAPTURE TIMINGS
CAP1 and CAP2 (Capture Mode)
50 52
51
TABLE 19-7:
Parameter No. 50 51 52 *
CAPTURE REQUIREMENTS
Min 10 * 10 * 2TCY N Typ Max Units Conditions -- -- -- -- -- -- ns ns ns N = prescale value (4 or 16)
Sym Characteristic TccL Capture1 and Capture2 input low time TccH Capture1 and Capture2 input high time TccP Capture1 and Capture2 input period
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
FIGURE 19-8: PWM TIMINGS
PWM1 and PWM2 (PWM Mode) 53 54
TABLE 19-8:
Parameter No. 53 54 *
PWM REQUIREMENTS
Min Typ Max Units Conditions
Sym Characteristic
TccR PWM1 and PWM2 output rise time -- 10 * 35 * ns TccF PWM1 and PWM2 output fall time -- 10 * 35 * ns These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
DS30412C-page 188
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-9: USART MODULE: SYNCHRONOUS TRANSMISSION (MASTER/SLAVE) TIMING
RA5/TX/CK pin RA4/RX/DT pin 120 122
121
121
TABLE 19-9:
Param No. Sym 120
SYNCHRONOUS TRANSMISSION REQUIREMENTS
Characteristic PIC17CR42/42A/43/R43/44 PIC17LCR42/42A/43/R43/44 Min -- -- -- -- -- -- Typ -- -- -- -- -- -- Max 50 75 25 40 25 40 Units Conditions ns ns ns ns ns ns
TckH2dtV SYNC XMIT (MASTER & SLAVE) Clock high to data out valid TckRF TdtRF
121 122
Clock out rise time and fall time PIC17CR42/42A/43/R43/44 (Master Mode) PIC17LCR42/42A/43/R43/44 Data out rise time and fall time PIC17CR42/42A/43/R43/44 PIC17LCR42/42A/43/R43/44
Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested.
FIGURE 19-10: USART MODULE: SYNCHRONOUS RECEIVE (MASTER/SLAVE) TIMING
RA5/TX/CK pin RA4/RX/DT pin 126
125
TABLE 19-10: SYNCHRONOUS RECEIVE REQUIREMENTS
Parameter No. 125 126 Sym TdtV2ckL TckL2dtl Characteristic SYNC RCV (MASTER & SLAVE) Data hold before CK (DT hold time) Data hold after CK (DT hold time) Min 15 15 Typ -- -- Max -- -- Units Conditions ns ns
Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested.
(c) 1996 Microchip Technology Inc.
DS30412C-page 189
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-11: MEMORY INTERFACE WRITE TIMING (NOT SUPPORTED IN PIC17LC4X DEVICES)
Q1 Q2 Q3 Q4 Q1 Q2
OSC1
ALE
OE WR 150 AD<15:0> addr out
151
154 data out 152 153 addr out
TABLE 19-11: MEMORY INTERFACE WRITE REQUIREMENTS (NOT SUPPORTED IN PIC17LC4X DEVICES)
Parameter No. 150 151 152 153 154 * Sym TadV2alL TalL2adI TadV2wrL TwrH2adI TwrL Characteristic AD<15:0> (address) valid to ALE (address setup time) ALE to address out invalid (address hold time) Data out valid to WR (data setup time) WR to data out invalid (data hold time) WR pulse width Min 0.25Tcy - 10 0 0.25Tcy - 40 -- -- Typ -- -- -- 0.25TCY 0.25TCY Max -- -- -- -- -- Units Conditions ns ns ns ns ns
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
DS30412C-page 190
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 19-12: MEMORY INTERFACE READ TIMING (NOT SUPPORTED IN PIC17LC4X DEVICES)
Q1 Q2 Q3 Q4 Q1 Q2
OSC1 166 ALE OE 164 168 160 165 AD<15:0> Addr out 150 WR '1' 167 151 Data in 162 163 '1' 161 Addr out
TABLE 19-12: MEMORY INTERFACE READ REQUIREMENTS (NOT SUPPORTED IN PIC17LC4X DEVICES)
Parameter No. 150 151 160 161 162 163 164 165 166 167 168 * Sym TadV2alL TalL2adI TadZ2oeL ToeH2adD TadV2oeH ToeH2adI TalH ToeL TalH2alH Tacc Toe Characteristic AD15:AD0 (address) valid to ALE (address setup time) ALE to address out invalid (address hold time) AD15:AD0 hi-impedance to OE OE to AD15:AD0 driven Data in valid before OE (data setup time) OEto data in invalid (data hold time) ALE pulse width OE pulse width ALE to ALE(cycle time) Address access time Output enable access time (OE low to Data Valid) Min 0.25Tcy - 10 5* 0* 0.25Tcy - 15 35 0 -- 0.5Tcy - 35 -- -- -- Typ -- -- -- -- -- -- 0.25TCY -- TCY -- -- Max -- -- -- -- -- -- -- -- -- 0.75TCY - 30 0.5TCY - 45 Units Conditions ns ns ns ns ns ns ns ns ns ns ns
These parameters are characterized but not tested. Data in "Typ" column is at 5V, 25C unless otherwise stated. These parameters are for design guidance only and are not tested. This specification ensured by design.
(c) 1996 Microchip Technology Inc.
DS30412C-page 191
PIC17C4X
NOTES:
DS30412C-page 192
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44
20.0
PIC17CR42/42A/43/R43/44 DC AND AC CHARACTERISTICS
The graphs and tables provided in this section are for design guidance and are not tested nor guaranteed. In some graphs or tables the data presented is outside specified operating range (e.g. outside specified VDD range). This is for information only and devices are ensured to operate properly only within the specified range. The data presented in this section is a statistical summary of data collected on units from different lots over a period of time. "Typical" represents the mean of the distribution while "max" or "min" represents (mean + 3) and (mean - 3) respectively where is standard deviation.
TABLE 20-1:
Pin Name
PIN CAPACITANCE PER PACKAGE TYPE
Typical Capacitance (pF) 40-pin DIP 44-pin PLCC 10 20 44-pin MQFP 10 20 44-pin TQFP 10 20
All pins, except MCLR, VDD, and VSS MCLR pin
10 20
FIGURE 20-1: TYPICAL RC OSCILLATOR FREQUENCY vs. TEMPERATURE
FOSC FOSC (25C) 1.10 1.08 1.06 1.04 1.02 1.00 VDD = 5.5V 0.98 0.96 0.94 VDD = 3.5V 0.92 0.90 0 10 20 25 30 T(C) 40 50 60 70 Rext 10 k Cext = 100 pF Frequency normalized to +25C
(c) 1996 Microchip Technology Inc.
DS30412C-page 193
This document was created with FrameMaker 4 0 4
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-2: TYPICAL RC OSCILLATOR FREQUENCY vs. VDD
4.0 3.5 3.0 FOSC (MHz) 2.5 2.0 1.5 Cext = 22 pF, T = 25C 1.0 0.5 0.0 4.0 4.5 5.0 VDD (Volts) R = 100k 5.5 6.0 6.5 R = 10k
FIGURE 20-3: TYPICAL RC OSCILLATOR FREQUENCY vs. VDD
4.0 3.5 3.0 FOSC (MHz) 2.5 2.0 1.5 1.0 Cext = 100 pF, T = 25C 0.5 0.0 4.0 4.5 5.0 VDD (Volts) 5.5 6.0 6.5 R = 100k R = 10k R = 5.1k R = 3.3k
DS30412C-page 194
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-4: TYPICAL RC OSCILLATOR FREQUENCY vs. VDD
2.0 1.8 1.6 1.4 1.2 FOSC (MHz) R = 5.1k 1.0 0.8 0.6 0.4 Cext = 300 pF, T = 25C 0.2 0.0 4.0 4.5 5.0 VDD (Volts) R = 160k 5.5 6.0 6.5 R = 10k R = 3.3k
TABLE 20-2:
Cext 22 pF
RC OSCILLATOR FREQUENCIES
Rext 10k 100k 3.3k 5.1k 10k 100k 3.3k 5.1k 10k 160k 3.33 MHz 353 kHz 3.54 MHz 2.43 MHz 1.30 MHz 129 kHz 1.54 MHz 980 kHz 564 kHz 35 kHz Average Fosc @ 5V, 25C 12% 13% 10% 14% 17% 10% 14% 12% 16% 18%
100 pF
300 pF
(c) 1996 Microchip Technology Inc.
DS30412C-page 195
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-5: TRANSCONDUCTANCE (gm) OF LF OSCILLATOR vs. VDD
500 450 400 350 Max @ -40C 300 gm(A/V) Typ @ 25C 250 200 150 Min @ 85C 100 50 0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0
FIGURE 20-6: TRANSCONDUCTANCE (gm) OF XT OSCILLATOR vs. VDD
20 18 Max @ -40C 16 14 Typ @ 25C 12 gm(mA/V) 10 8 6 Min @ 85C 4 2 0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0
DS30412C-page 196
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-7: TYPICAL IDD vs. FREQUENCY (EXTERNAL CLOCK 25C)
100000
10000
IDD (A)
1000 7.0V 6.5V 6.0V 5.5V 5.0V 4.5V 4.0V
100
10 10k
100k
1M External Clock Frequency (Hz)
10M
100M
FIGURE 20-8: MAXIMUM IDD vs. FREQUENCY (EXTERNAL CLOCK 125C TO -40C)
100000
10000
IDD (A) 1000
7.0V 6.5V 6.0V 5.5V 5.0V 4.5V 4.0V
100 10k 100k 1M External Clock Frequency (Hz) 10M 100M
(c) 1996 Microchip Technology Inc.
DS30412C-page 197
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-9: TYPICAL IPD vs. VDD WATCHDOG DISABLED 25C
12
10
8 IPD(nA)
6
4
2
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
FIGURE 20-10: MAXIMUM IPD vs. VDD WATCHDOG DISABLED
1900 1800 1700 1600 1500 1400 1300 1200 1100 1000 900 800 700 600 500 400 300 200 100 0 4.0
IPD(nA)
Temp. = 85C
Temp. = 70C Temp. = 0C Temp. = -40C 6.5 7.0
4.5
5.0
5.5
6.0
VDD (Volts)
DS30412C-page 198
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-11: TYPICAL IPD vs. VDD WATCHDOG ENABLED 25C
30
25
20 IPD(A)
15
10
5
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
FIGURE 20-12: MAXIMUM IPD vs. VDD WATCHDOG ENABLED
60
50 -40C 40 IPD(A) 70C 0C 85C 30
20
10
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
(c) 1996 Microchip Technology Inc.
DS30412C-page 199
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-13: WDT TIMER TIME-OUT PERIOD vs. VDD
30
25 Max. 85C 20 WDT Period (ms) Max. 70C 15 Min. 0C Typ. 25C
10 Min. -40C 5
0 4.0 4.5 5.0 5.5 VDD (Volts) 6.0 6.5 7.0
FIGURE 20-14: IOH vs. VOH, VDD = 3V
0 -2 -4 IOH(mA) -6 -8 -10 -12 -14 -16 -18 0.0 0.5 1.0 1.5 VDD (Volts) 2.0 2.5 3.0 Max @ -40C Typ @ 25C Min @ 85C
DS30412C-page 200
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-15: IOH vs. VOH, VDD = 5V
0 IOH(mA) -5 -10 Min @ 85C -15 -20 Max @ -40C -25 -30 -35 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 Typ @ 25C
VDD (Volts)
FIGURE 20-16: IOL vs. VOL, VDD = 3V
30 Max. -40C 25 Typ. 25C 20 IOL(mA)
15 Min. +85C 10
5
0 0.0 0.5 1.0 1.5 VDD (Volts) 2.0 2.5 3.0
(c) 1996 Microchip Technology Inc.
DS30412C-page 201
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-17: IOL vs. VOL, VDD = 5V
90 80 70 Max @ -40C IOH(mA) 60 50 40 30 20 10 0 0.0 0.5 1.0 1.5 VDD (Volts) 2.0 2.5 3.0 Min @ +85C Typ @ 25C
FIGURE 20-18: VTH (INPUT THRESHOLD VOLTAGE) OF I/O PINS (TTL) VS. VDD
2.0 1.8 Max (-40C to +85C) 1.6 Typ @ 25C VTH(Volts) 1.4 1.2 1.0 Min (-40C to +85C) 0.8 0.6 2.5
3.0
3.5
4.0 VDD (Volts)
4.5
5.0
5.5
6.0
DS30412C-page 202
(c) 1996 Microchip Technology Inc.
PIC17C4X
Applicable Devices 42 R42 42A 43 R43 44 FIGURE 20-19: VTH, VIL of I/O PINS (SCHMITT TRIGGER) VS. VDD
5.0 VIH, max (-40C to +85C) 4.5 VIH, typ (25C) 4.0 VIH, min (-40C to +85C) 3.5 VIH, VIL(Volts) 3.0 2.5 2.0 1.5 1.0 0.5 0.0 2.0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0 VIL, max (-40C to +85C) VIL, typ (25C) VIL, min (-40C to +85C)
FIGURE 20-20: VTH (INPUT THRESHOLD VOLTAGE) OF OSC1 INPUT (IN XT AND LF MODES) vs. VDD
3.4 3.2 3.0 Max (-40C to +85C) 2.8 VTH,(Volts) 2.6 2.4 2.2 2.0 Min (-40C to +85C) 1.8 1.6 1.4 1.2 1.0 2.5 3.0 3.5 4.0 VDD (Volts) 4.5 5.0 5.5 6.0 Typ (25C)
(c) 1996 Microchip Technology Inc.
DS30412C-page 203
PIC17C4X
NOTES:
DS30412C-page 204
(c) 1996 Microchip Technology Inc.
PIC17C4X
21.0
21.1
PACKAGING INFORMATION
40-Lead Ceramic CERDIP Dual In-line, and CERDIP Dual In-line with Window (600 mil)
N
E1 E Pin No. 1 Indicator Area
eA eB
C
D S Base Plane Seating Plane B1 B D1 e1 L A1 A3 A A2 S1
Package Group: Ceramic CERDIP Dual In-Line (CDP) Millimeters Symbol A A1 A2 A3 B B1 C D D1 E E1 e1 eA eB L N S S1 Min 0 4.318 0.381 3.810 3.810 0.355 1.270 0.203 51.435 48.260 15.240 12.954 2.540 14.986 15.240 3.175 40 1.016 0.381 Max 10 5.715 1.778 4.699 4.445 0.585 1.651 0.381 52.705 48.260 15.875 15.240 2.540 16.002 18.034 3.810 40 2.286 1.778 Notes Min 0 0.170 0.015 0.150 0.150 0.014 0.050 0.008 2.025 1.900 0.600 0.510 0.100 0.590 0.600 0.125 40 0.040 0.015 Inches Max 10 0.225 0.070 0.185 0.175 0.023 0.065 0.015 2.075 1.900 0.625 0.600 0.100 0.630 0.710 0.150 40 0.090 0.070 Notes
Typical Typical Reference
Typical Typical Reference
Reference Typical
Reference Typical
(c) 1996 Microchip Technology Inc.
DS30412C-page 205
This document was created with FrameMaker 4 0 4
PIC17C4X
21.2 40-Lead Plastic Dual In-line (600 mil)
N eA eB
E1 E Pin No. 1 Indicator Area
C
D S Base Plane Seating Plane B1 B D1 e1 L A1 A2 A S1
Package Group: Plastic Dual In-Line (PLA) Millimeters Symbol A A1 A2 B B1 C D D1 E E1 e1 eA eB L N S S1 Min 0 - 0.381 3.175 0.355 1.270 0.203 51.181 48.260 15.240 13.462 2.489 15.240 15.240 2.921 40 1.270 0.508 Max 10 5.080 - 4.064 0.559 1.778 0.381 52.197 48.260 15.875 13.970 2.591 15.240 17.272 3.683 40 - - Notes Min 0 - 0.015 0.125 0.014 0.050 0.008 2.015 1.900 0.600 0.530 0.098 0.600 0.600 0.115 40 0.050 0.020 Inches Max 10 0.200 - 0.160 0.022 0.070 0.015 2.055 1.900 0.625 0.550 0.102 0.600 0.680 0.145 40 - - Notes
Typical Typical Reference
Typical Typical Reference
Typical Reference
Typical Reference
DS30412C-page 206
(c) 1996 Microchip Technology Inc.
PIC17C4X
21.3 44-Lead Plastic Leaded Chip Carrier (Square)
D 0.177 .007 S B D-E S D1 -A-D3 0.38 .015 E1 -BE 0.38 .015 1.27 .050 2 Sides A D3/E3 D2 3 -GF-G S E2 F-G S 4 4 0.812/0.661 N Pics .032/.026 -HA1 D -C0.177 .007 S B A S 2 Sides 9
0.101 Seating .004 Plane
3 -F-
8
3
-E-
0.177 .007 S A F-G S 10 0.254 .010 Max 0.508 .020 6 -C1.651 .065 R 1.14/0.64 .045/.025 1.651 .065 R 1.14/0.64 .045/.025 0.64 Min .025 5 0.533/0.331 .021/.013 0.177 , D-E S .007 M A F-G S 0.812/0.661 3 .032/.026
0.254 .010 Max 2 -H6
11
11 0.508 .020 -H2
1.524 .060 Min
Package Group: Plastic Leaded Chip Carrier (PLCC) Millimeters Symbol A A1 D D1 D2 D3 E E1 E2 E3 N CP LT Min 4.191 2.413 17.399 16.510 15.494 12.700 17.399 16.510 15.494 12.700 44 - 0.203 Max 4.572 2.921 17.653 16.663 16.002 12.700 17.653 16.663 16.002 12.700 44 0.102 0.381 Notes Min 0.165 0.095 0.685 0.650 0.610 0.500 0.685 0.650 0.610 0.500 44 - 0.008 Inches Max 0.180 0.115 0.695 0.656 0.630 0.500 0.695 0.656 0.630 0.500 44 0.004 0.015 Notes
Reference
Reference
Reference
Reference
(c) 1996 Microchip Technology Inc.
DS30412C-page 207
PIC17C4X
21.4 44-Lead Plastic Surface Mount (MQFP 10x10 mm Body 1.6/0.15 mm Lead Form)
4D D1 5 D3 Index area 6 0.13 R min. PARTING LINE 7 0.05 mm/mm A-B 0.20 min. 0.20 M C A-B S 0.20 M H A-B S DS DS
0.13/0.30 R
9
b
L E3 C E1 E 1.60 Ref. 0.20 M C A-B S DS 4
TYP 4x 10 e B 0.20 M H A-B S 0.05 mm/mm D A2 Base Plane A1 A Seating Plane DS 5 7
Package Group: Plastic MQFP Millimeters Symbol A A1 A2 b C D D1 D3 E E1 E3 e L N CP Min 0 2.000 0.050 1.950 0.300 0.150 12.950 9.900 8.000 12.950 9.900 8.000 0.800 0.730 44 0.102 Max 7 2.350 0.250 2.100 0.450 0.180 13.450 10.100 8.000 13.450 10.100 8.000 0.800 1.030 44 - Notes Min 0 0.078 0.002 0.768 0.011 0.006 0.510 0.390 0.315 0.510 0.390 0.315 0.031 0.028 44 0.004 Inches Max 7 0.093 0.010 0.083 0.018 0.007 0.530 0.398 0.315 0.530 0.398 0.315 0.032 0.041 44 - Notes
Typical
Typical
Reference
Reference
Reference
Reference
DS30412C-page 208
(c) 1996 Microchip Technology Inc.
PIC17C4X
21.5 44-Lead Plastic Surface Mount (TQFP 10x10 mm Body 1.0/0.10 mm Lead Form)
D
1.0o (0.039o) Ref.
D1
Pin#1 2
Pin#1 2
E E1
11/13(4x) 0 Min 11/13(4x) Detail B
e Option 1 (TOP side)
3.0o (0.118o) Ref. Option 2 (TOP side) A1 A2 L 1.00 Ref. A Base Metal Lead Finish
R 1 0.08 Min R 0.08/0.20
Gage Plane 0.250
b
L c1 L1 1.00 Ref Detail B
Detail B
Detail A
c b1 Detail A
S 0.20 Min
Package Group: Plastic TQFP Millimeters Symbol A A1 A2 D D1 E E1 L e b b1 c c1 N Min 1.00 0.05 0.95 11.75 9.90 11.75 9.90 0.45 0.80 BSC 0.30 0.30 0.09 0.09 44 0 0.45 0.40 0.20 0.16 44 7 0.012 0.012 0.004 0.004 44 0 Max 1.20 0.15 1.05 12.25 10.10 12.25 10.10 0.75 Notes Min 0.039 0.002 0.037 0.463 0.390 0.463 0.390 0.018 0.031 BSC 0.018 0.016 0.008 0.006 44 7 Inches Max 0.047 0.006 0.041 0.482 0.398 0.482 0.398 0.030 Notes
Note 1: Dimensions D1 and E1 do not include mold protrusion. Allowable mold protrusion is 0.25m/m (0.010") per side. D1 and E1 dimensions including mold mismatch. 2: Dimension "b" does not include Dambar protrusion, allowable Dambar protrusion shall be 0.08m/m (0.003")max. 3: This outline conforms to JEDEC MS-026.
(c) 1996 Microchip Technology Inc.
DS30412C-page 209
PIC17C4X
21.6 Package Marking Information
40-Lead PDIP/CERDIP XXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX AABBCDE Example PIC17C43-25I/P L006 9441CCA
40 Lead CERDIP Windowed XXXXXXXXXXX XXXXXXXXXXX XXXXXXXXXXX AABBCDE 44-Lead PLCC
Example PIC17C44 /JW L184 9444CCT Example
XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX AABBCDE 44-Lead MQFP XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX AABBCDE 44-Lead TQFP XXXXXXXXXX XXXXXXXXXX XXXXXXXXXX AABBCDE Legend: MM...M XX...X AA BB C
PIC17C42 -16I/L L013 9445CCN Example PIC17C44 -25/PT L247 9450CAT Example PIC17C44 -25/TQ L247 9450CAT
Microchip part number information Customer specific information* Year code (last 2 digits of calendar year) Week code (week of January 1 is week `01') Facility code of the plant at which wafer is manufactured C = Chandler, Arizona, U.S.A., S = Tempe, Arizona, U.S.A. D Mask revision number E Assembly code of the plant or country of origin in which part was assembled Note: In the event the full Microchip part number cannot be marked on one line, it will be carried over to the next line thus limiting the number of available characters for customer specific information. * Standard OTP marking consists of Microchip part number, year code, week code, facility code, mask rev#, and assembly code. For OTP marking beyond this, certain price adders apply. Please check with your Microchip Sales Office. For QTP devices, any special marking adders are included in QTP price.
DS30412C-page 210
(c) 1996 Microchip Technology Inc.
PIC17C4X
APPENDIX A: MODIFICATIONS
The following is the list of modifications over the PIC16CXX microcontroller family: 1. Instruction word length is increased to 16-bit. This allows larger page sizes both in program memory (8 Kwords verses 2 Kwords) and register file (256 bytes versus 128 bytes). Four modes of operation: microcontroller, protected microcontroller, extended microcontroller, and microprocessor. 22 new instructions. The MOVF, TRIS and OPTION instructions have been removed. 4 new instructions for transferring data between data memory and program memory. This can be used to "self program" the EPROM program memory. Single cycle data memory to data memory transfers possible (MOVPF and MOVFP instructions). These instructions do not affect the Working register (WREG). W register (WREG) is now directly addressable. A PC high latch register (PCLATH) is extended to 8-bits. The PCLATCH register is now both readable and writable. Data memory paging is redefined slightly. DDR registers replaces function of TRIS registers. Multiple Interrupt vectors added. This can decrease the latency for servicing the interrupt. Stack size is increased to 16 deep. BSR register for data memory paging. Wake up from SLEEP operates slightly differently. The Oscillator Start-Up Timer (OST) and Power-Up Timer (PWRT) operate in parallel and not in series. PORTB interrupt on change feature works on all eight port pins. TMR0 is 16-bit plus 8-bit prescaler. Second indirect addressing register added (FSR1 and FSR2). Configuration bits can select the FSR registers to auto-increment, auto-decrement, remain unchanged after an indirect address. Hardware multiplier added (8 x 8 16-bit) (PIC17C43 and PIC17C44 only). Peripheral modules operate slightly differently. Oscillator modes slightly redefined. Control/Status bits and registers have been placed in different registers and the control bit for globally enabling interrupts has inverse polarity. Addition of a test mode pin. In-circuit serial programming is not implemented.
APPENDIX B: COMPATIBILITY
To convert code written for PIC16CXX to PIC17CXX, the user should take the following steps: 1. 2. 3. Remove any TRIS and OPTION instructions, and implement the equivalent code. Separate the interrupt service routine into its four vectors. Replace: MOVF REG1, W with: MOVFP REG1, WREG Replace: MOVF REG1, W MOVWF REG2 with: MOVPF REG1, REG2 ; Addr(REG1)<20h or MOVFP REG1, REG2 ; Addr(REG2)<20h Note: If REG1 and REG2 are both at addresses greater then 20h, two instructions are required. MOVFP REG1, WREG ; MOVPF WREG, REG2 ; Ensure that all bit names and register names are updated to new data memory map location. Verify data memory banking. Verify mode of operation for indirect addressing. Verify peripheral routines for compatibility. Weak pull-ups are enabled on reset.
2.
3.
4.
4.
5.
6. 7.
5. 6. 7. 8. 9.
8. 9. 10. 11. 12. 13. 14.
To convert code from the PIC17C42 to all the other PIC17C4X devices, the user should take the following steps. 1. If the hardware multiply is to be used, ensure that any variables at address 18h and 19h are moved to another address. Ensure that the upper nibble of the BSR was not written with a non-zero value. This may cause unexpected operation since the RAM bank is no longer 0. The disabling of global interrupts has been enhanced so there is no additional testing of the GLINTD bit after a BSF CPUSTA, GLINTD instruction.
2.
15. 16. 17.
3.
18. 19. 20. 21.
22. 23.
(c) 1996 Microchip Technology Inc.
DS30412C-page 211
This document was created with FrameMaker 4 0 4
PIC17C4X
APPENDIX C: WHAT'S NEW
The structure of the document has been made consistent with other data sheets. This ensures that important topics are covered across all PIC16/17 families. Here is an overview of new features. Added the following devices: PIC17CR42 PIC17C42A PIC17CR43 A 33 MHz option is now available.
APPENDIX D: WHAT'S CHANGED
To make software more portable across the different PIC16/17 families, the name of several registers and control bits have been changed. This allows control bits that have the same function, to have the same name (regardless of processor family). Care must still be taken, since they may not be at the same special function register address. The following shows the register and bit names that have been changed: Old Name TX8/9 RC8/9 RCD8 TXD8 New Name TX9 RX9 RX9D TX9D
Instruction DECFSNZ corrected to DCFSNZ Instruction INCFSNZ corrected to INFSNZ Enhanced discussion on PWM to include equation for determining bits of PWM resolution. Section 13.2.2 and 13.3.2 have had the description of updating the FERR and RX9 bits enhanced. The location of configuration bit PM2 was changed (Figure 6-1 and Figure 14-1). Enhanced description of the operation of the INTSTA register. Added note to discussion of interrupt operation. Tightened electrical spec D110. Corrected steps for setting up USART Asynchronous Reception.
DS30412C-page 212
(c) 1996 Microchip Technology Inc.
E.1 PIC14000 Devices
(c) 1996 Microchip Technology Inc. Clock
Hz )
Memory
Peripherals
Features
io at
n
(M
or
y
)
(x
14
wo
r
) ds
y nc
o
r pe fO
M
em
s te by
I SP
/I
2
C
,U
R SA
T)
am
m
in
g
APPENDIX E: PIC16/17 MICROCONTROLLERS
) r lts gr te ls ro ip Vo s er nne ( e v s) lP am ch ( ( na ( e e r rc nle ria qu ry s) ng og Co Ch ou u e e o a rt( S lO Pr D) Fr R od tS em pt ins na es Po A/ es M ui um M ge rM ru e h-r O rc tio tur al r i e im ri R ta lta di a op ig te /O P m -C ax Se In Sl (h EP I Vo Da Ti Ad Fe M In
Pa
a ck
ge
s
This document was created with FrameMaker 4 0 4
4K 192 TMR0 I2C/ ADTMR SMBus 14 11 22 2.7-6.0 Internal Oscillator, Bandgap Reference, Temperature Sensor, Calibration Factors, Yes Low Voltage Detector, SLEEP, HIBERNATE, Comparators with Programmable References (2)
PIC14000
20
28-pin DIP, SOIC, SSOP (.300 mil)
PIC17C4X
DS30412C-page 213
E.2
s)
yte
)
cy of O pe ra tio n P (M ro g Hz (x ram ) 12 M wo em rd or s) y
y( b
lts
en
or
)
qu
(s
(V o
em
le
e
M
ng
In
str u
cti
on
s
Fr e
od u
at a
Ra
of
um
M
D
ns
e
im
OM
M
er
Pi
ag
m
be r
ax
M
EP R
M
RO
RA
Ti m
I/O
PIC16C52 20 20 20 20 20 20 20 20 20 -- 2K 73 TMR0 2K -- 73 TMR0 -- 2K 72 TMR0 20 12 12 2K -- 72 TMR0 20 1K -- 25 TMR0 12 512 -- 24 TMR0 20 2.5-6.25 2.5-6.25 2.5-6.25 2.5-6.25 2.0-6.25 2.5-6.25 -- 512 25 TMR0 12 2.0-6.25 512 -- 25 TMR0 12 2.0-6.25 33 33 33 33 33 33 33 33 512 -- 25 TMR0 12 2.5-6.25 33
4
384
--
25
TMR0
12
2.5-6.25
Vo lt
33
Nu
18-pin DIP, SOIC 18-pin DIP, SOIC; 20-pin SSOP 18-pin DIP, SOIC; 20-pin SSOP 18-pin DIP, SOIC; 20-pin SSOP 28-pin DIP, SOIC, SSOP 18-pin DIP, SOIC; 20-pin SSOP 28-pin DIP, SOIC, SSOP 28-pin DIP, SOIC, SSOP 18-pin DIP, SOIC; 20-pin SSOP 18-pin DIP, SOIC; 20-pin SSOP
PIC16C54
PIC16C54A
PIC16CR54A
PIC16C55
PIC16C56
PIC16C57
PIC16CR57B
PIC16C58A
PIC16CR58A
(c) 1996 Microchip Technology Inc.
All PIC16/17 Family devices have Power-On Reset, selectable Watchdog Timer, selectable code protect and high I/O current capability.
P
ac k
ag
es
DS30412C-page 214
PIC17C4X
PIC16C5X Family of Devices
Clock
Memory
Peripherals
Features
E.3
(c) 1996 Microchip Technology Inc. Clock
n tio (M H z)
Memory
Peripherals
Features
PIC16CXXX Family of Devices
y or em s) M rd ge ra mo ta pe ol ra 4 w O ) V of og x1 es ce Pr ( yt cy ) es (b en (s en ) rc r u e ry fe ou r(s ul eq o S to Fr Re od em ra pt M al ns um M rM O pa rn rru Pi e a im e e at ax im PR om nt nt /O I I I D T E M C
t se Re s t R ou ge e nka ag c lt ow Pa Vo Br
g an e
-- -- -- Yes 18-pin DIP, SOIC; 20-pin SSOP 18-pin DIP, SOIC; 20-pin SSOP 18-pin DIP, SOIC; 20-pin SSOP 18-pin DIP, SOIC; 20-pin SSOP
(V
ol
ts
)
PIC16C554 20 20 20 20 20 2K 128 TMR0 2 Yes 4 13 1K 80 TMR0 2 Yes 4 13 512 80 TMR0 2 Yes 4 13 2K 128 TMR0 -- -- 3 13 2.5-6.0 2.5-6.0 2.5-6.0 2.5-6.0 1K 80 TMR0 -- -- 3 13 2.5-6.0
20
512
80
TMR0
--
--
3
13
2.5-6.0
PIC16C556
PIC16C558
PIC16C620
PIC16C621
Yes Yes
18-pin DIP, SOIC; 20-pin SSOP 18-pin DIP, SOIC; 20-pin SSOP
PIC16C622
All PIC16/17 Family devices have Power-on Reset, selectable Watchdog Timer, selectable code protect and high I/O current capability. All PIC16C6XXX Family devices use serial programming with clock pin RB6 and data pin RB7.
PIC17C4X
DS30412C-page 215
E.4
Clock
(M H z)
Memory
s)
Peripherals
Features
DS30412C-page 216
y e( or ) ul g em s) RT od in ti M rd M m SA ra m wo e U m M p , ) ra ra O ) 2C W lts og 14 of og /I /P t es y Vo Pr (x yt s t Pr re or PI ) c ( l s P (b e ce se (S en pa ia e( ur ry m qu ve ng s) er ul Re o e a t( la t So Co Fr R tS od or es em ou lS e/ ui pt ins M M um lP ge nag rM ur lle rc O ru e r P w M im R pt ta lta ck ra ria Ci o m te ax Se Da In In Br Pa Ca EP RO Ti Pa Vo I/O M
on
PIC17C4X
PIC16C6X Family of Devices
PIC16C62 20 20 20 20 20 20 20 20 20 20 -- 4K 192 TMR0, TMR1, TMR2 4K -- 192 TMR0, TMR1, TMR2 4K -- 192 TMR0, TMR1, TMR2 -- 2K 128 TMR0, TMR1, TMR2 1 SPI/I2C Yes 2K -- 128 TMR0, TMR1, TMR2 1 SPI/I2C Yes 8 8 11 11 2 SPI/I2C, Yes USART 11 2K -- 128 TMR0, TMR1, TMR2 1 SPI/I2C Yes 8 33 33 33 33 33 33 -- 4K 192 TMR0, TMR1, TMR2 2 SPI/I2C, USART -- 10 22 2.5-6.0 3.0-6.0 2.5-6.0 2.5-6.0 3.0-6.0 2.5-6.0 2.5-6.0 4K -- 192 TMR0, TMR1, TMR2 2 SPI/I2C, USART -- 10 22 2.5-6.0 Yes Yes Yes Yes Yes Yes Yes Yes -- 2K 128 TMR0, TMR1, TMR2 1 SPI/I2C -- 7 22 2.5-6.0 Yes 2K -- 128 TMR0, TMR1, TMR2 1 SPI/I2C -- 7 22 2.5-6.0 Yes
20
2K
--
128 TMR0, TMR1, TMR2
1 SPI/I2C -- 7 22 3.0-6.0 Yes --
28-pin SDIP, SOIC, SSOP
PIC16C62A(1)
Yes 28-pin SDIP, SOIC, SSOP Yes 28-pin SDIP, SOIC, SSOP Yes 28-pin SDIP, SOIC Yes 28-pin SDIP, SOIC -- 40-pin DIP; 44-pin PLCC, MQFP Yes 40-pin DIP; 44-pin PLCC, MQFP, TQFP Yes 40-pin DIP; 44-pin PLCC, MQFP, TQFP -- 40-pin DIP; 44-pin PLCC, MQFP Yes 40-pin DIP; 44-pin PLCC, MQFP, TQFP Yes 40-pin DIP; 44-pin PLCC, MQFP, TQFP
PIC16CR62(1)
PIC16C63
PIC16CR63(1)
PIC16C64
PIC16C64A(1)
PIC16CR64(1)
PIC16C65
2 SPI/I2C, Yes USART 2 SPI/I2C, Yes USART
PIC16C65A(1)
PIC16CR65(1)
(c) 1996 Microchip Technology Inc.
All PIC16/17 family devices have Power-on Reset, selectable Watchdog Timer, selectable code protect, and high I/O current capability. All PIC16C6X family devices use serial programming with clock pin RB6 and data pin RB7. Note 1: Please contact your local sales office for availability of these devices.
E.5
Clock
(M ) Hz
Memory
d s)
Peripherals
ul e( s)
Features
ne ls
(c) 1996 Microchip Technology Inc.
PIC16C7X Family of Devices
g in m m ,U M 2C C ) O ra ) ts t) W em of t ol bi og es I/I /P M s yt or cy 8t (V ) Pr re (SP e n m s P l (b e r( se rc pa s) ra ia ue e( ry ve ng rte m ou ul ( er og eq Re o t a e la S s t Fr Pr R od Co Por tS nv em lS pt ins ou ge M e e/ ui um M rM O lle nCo ur rial ka rru ag irc m P e R i c ra ta lt pt D te ow m -C ax EP Pa Se In A/ Pa I/O Vo Da Ti M In Br Ca
p a er n tio
y or
(x
14
r wo
M
od
R SA
T)
n ha
PIC16C710 20 20 20 20 20 20 20 4K 4K 192 TMR0, 2 SPI/I2C, Yes TMR1, TMR2 USART 192 TMR0, 2 SPI/I2C, Yes TMR1, TMR2 USART 4K 192 TMR0, 2 SPI/I2C, TMR1, TMR2 USART -- 5 8 8 4K 192 TMR0, 2 SPI/I2C, TMR1, TMR2 USART -- 5 11 11 12 12 2K 128 TMR0, 1 SPI/I2C TMR1, TMR2 -- 5 8 22 22 22 33 33 1K 68 TMR0 -- -- -- 4 4 13 1K 36 TMR0 -- -- -- 4 4 13 3.0-6.0 3.0-6.0 2.5-6.0 3.0-6.0 2.5-6.0 3.0-6.0 2.5-6.0
20
512
36
TMR0
--
--
--
4
4
13
3.0-6.0
Yes Yes Yes Yes Yes Yes Yes Yes
Yes 18-pin DIP, SOIC; 20-pin SSOP -- 18-pin DIP, SOIC Yes 18-pin DIP, SOIC; 20-pin SSOP Yes 28-pin SDIP, SOIC, SSOP -- 28-pin SDIP, SOIC Yes 28-pin SDIP, SOIC -- 40-pin DIP; 44-pin PLCC, MQFP Yes 40-pin DIP; 44-pin PLCC, MQFP, TQFP
PIC16C71 PIC16C711
PIC16C72
PIC16C73
PIC16C73A(1)
PIC16C74
PIC16C74A(1)
PIC17C4X
All PIC16/17 Family devices have Power-on Reset, selectable Watchdog Timer, selectable code protect and high I/O current capability. All PIC16C7X Family devices use serial programming with clock pin RB6 and data pin RB7. Note 1: Please contact your local sales office for availability of these devices.
DS30412C-page 217
E.6
h
as
Fl
DS30412C-page 218 Clock
n tio (M ) Hz
PIC17C4X
Memory
em
e yt s)
Peripherals
Features
PIC16C8X Family of Devices
or
y
F
q re
ue
n
cy
of
O
pe
ra
Pr
or y (b
M RO M
r og
em
am
M
M
a
xim
um
EE
O PR
Da
ta
M
Da
T
TMR0 TMR0 TMR0 TMR0 TMR0 4 4 4 4 4
ta
im
EE
er M
P
o
RO
M
l du
(
e(
t by
s)
es
)
es rc ge ou an S s R pt ins e ge ag ka rru P lt c te In Pa Vo I/O
ol (V
ts
)
PIC16C84 PIC16F84(1) 10 10 10 10 -- -- 512 36 64 512 -- -- 36 64 -- -- 1K 68 64 1K -- -- 68 64 PIC16CR84(1) PIC16F83(1) PIC16CR83(1)
10
--
1K
--
36
64
13 13 13 13 13
2.0-6.0 18-pin DIP, SOIC 2.0-6.0 18-pin DIP, SOIC 2.0-6.0 18-pin DIP, SOIC 2.0-6.0 18-pin DIP, SOIC 2.0-6.0 18-pin DIP, SOIC
All PIC16/17 family devices have Power-on Reset, selectable Watchdog Timer, selectable code protect, and high I/O current capability. All PIC16C8X family devices use serial programming with clock pin RB6 and data pin RB7. Note 1: Please contact your local sales office for availability of these devices.
(c) 1996 Microchip Technology Inc.
E.7
(c) 1996 Microchip Technology Inc. Clock
z) on H (M
Memory
or
M u od le
Peripherals
(s )
Features
ne ls
y
PIC16C9XX Family Of Devices
g in m m p M 2C C ) r O ra ts t) og tes) of /I PW t ol bi og Pr s e/ SPI y or cy 8(V ) Pr r e s P l et (b e en r( rc pa s) ( ia e( es qu ry ve ng rte m le ou ul ( er e o t a e la u S s tR s Fr R od Co Por tS nv in od em lS pt ins ou ge e/ ui M um M M ge rM lle nCo tP O rc ur rial ka rru i P e im c D ra ta R lta pt D te pu ow m -C ax Pa Se In A/ LC Pa I/O In Da Vo Ti EP M In Br Ca
er i at
am
em M
,U
R SA
T)
n ha
PIC16C923 4K 4 Com 32 Seg 176 TMR0, 1 SPI/I2C TMR1, TMR2 -- 5 9 25 27
8
4K
176 TMR0, 1 SPI/I2C TMR1, TMR2
--
--
4 Com 32 Seg
8
25
27
3.0-6.0 3.0-6.0
Yes Yes
-- --
64-pin SDIP(1), TQFP, 68-pin PLCC, DIE 64-pin SDIP(1), TQFP, 68-pin PLCC, DIE
PIC16C924
8
Note
All PIC16/17 Family devices have Power-on Reset, selectable Watchdog Timer, selectable code protect and high I/O current capability. All PIC16CXX Family devices use serial programming with clock pin RB6 and data pin RB7. 1: Please contact your local Microchip representative for availability of this package.
PIC17C4X
DS30412C-page 219
E.8
)
(M
Hz
n
io
y
(W or
ds
)
at
or
pe r
M
em
es
)
by t
O
(
T)
)
of
y
ts
s
y
or
SA R
ly
og ra m
)
pt
es
ol
U
en c
tip
(V
(s
ru
Pr
rc
u
em
le
)(
ul
e
ns
tr
uc t
io
ns
M
eq
te r
M
Fr
ta
rt( s
In
So u
ng
od u
o
re
Ra
of I
M
um
Da
al
pt
lP
ns
r
ru
M
ge
RO
im
er M
dw a
r
er n
Pi
AM
m
ax
RO
xt
te r
lta
be
EP
er ia
Ha
M
R
E
In
I/O
um
Ti
S
PIC17C42 25 25 25 25 25 8K 454 Yes -- 4K 454 Yes Yes Yes 4K -- 454 TMR0,TMR1, 2 2 TMR2,TMR3 Yes Yes Yes Yes Yes -- 2K 232 TMR0,TMR1, 2 2 TMR2,TMR3 Yes Yes Yes 11 11 11 11 2K -- 232 TMR0,TMR1, 2 2 TMR2,TMR3 Yes Yes Yes 11 33 33 33 33 33
25
2K
--
232
Ca p P tu W res M s
TMR0,TMR1, 2 2 TMR2,TMR3
Yes
--
Yes
11
33
4.5-5.5 2.5-6.0 2.5-6.0 2.5-6.0 2.5-6.0 2.5-6.0
Vo
55 58 58 58 58 58
N
40-pin DIP; 44-pin PLCC, MQFP 40-pin DIP; 44-pin PLCC, TQFP, MQFP 40-pin DIP; 44-pin PLCC, TQFP, MQFP 40-pin DIP; 44-pin PLCC, TQFP, MQFP
PIC17C42A
PIC17CR42
PIC17C43
PIC17CR43
PIC17C44
TMR0,TMR1, 2 2 TMR2,TMR3 TMR0,TMR1, 2 2 TMR2,TMR3
40-pin DIP; 44-pin PLCC, TQFP, MQFP 40-pin DIP; 44-pin PLCC, TQFP, MQFP
(c) 1996 Microchip Technology Inc.
All PIC16/17 Family devices have Power-on Reset, selectable Watchdog Timer, selectable code protect and high I/O current capability.
P
ac k
ag
es
DS30412C-page 220
PIC17C4X
PIC17CXX Family of Devices
Clock
Memory
Peripherals
Features
PIC17C4X
PIN COMPATIBILITY
Devices that have the same package type and VDD, VSS and MCLR pin locations are said to be pin compatible. This allows these different devices to operate in the same socket. Compatible devices may only requires minor software modification to allow proper operation in the application socket (ex., PIC16C56 and PIC16C61 devices). Not all devices in the same package size are pin compatible; for example, the PIC16C62 is compatible with the PIC16C63, but not the PIC16C55. Pin compatibility does not mean that the devices offer the same features. As an example, the PIC16C54 is pin compatible with the PIC16C71, but does not have an A/D converter, weak pull-ups on PORTB, or interrupts.
TABLE E-1:
PIN COMPATIBLE DEVICES
Pin Compatible Devices Package 8-pin 18-pin 20-pin
PIC12C508, PIC12C509 PIC16C54, PIC16C54A, PIC16CR54A, PIC16C56, PIC16C58A, PIC16CR58A, PIC16C61, PIC16C554, PIC16C556, PIC16C558 PIC16C620, PIC16C621, PIC16C622, PIC16C710, PIC16C71, PIC16C711, PIC16F83, PIC16CR83, PIC16C84, PIC16F84A, PIC16CR84 PIC16C55, PIC16C57, PIC16CR57B PIC16C62, PIC16CR62, PIC16C62A, PIC16C63, PIC16C72, PIC16C73, PIC16C73A PIC16C64, PIC16CR64, PIC16C64A, PIC16C65, PIC16C65A, PIC16C74, PIC16C74A PIC17C42, PIC17CR42, PIC17C42A, PIC17C43, PIC17CR43, PIC17C44 PIC16C923, PIC16C924
28-pin 28-pin 40-pin
40-pin 64/68-pin
(c) 1996 Microchip Technology Inc.
DS30412C-page 221
PIC17C4X
NOTES:
DS30412C-page 222
(c) 1996 Microchip Technology Inc.
PIC17C4X
APPENDIX F: ERRATA FOR PIC17C42 SILICON
The PIC17C42 devices that you have received have the following anomalies. At present there is no intention for future revisions to the present PIC17C42 silicon. If these cause issues for the application, it is recommended that you select the PIC17C42A device. Note: 1. New designs should use the PIC17C42A.
Design considerations
The device must not be operated outside of the specified voltage range. An external reset circuit must be used to ensure the device is in reset when a brown-out occurs or the VDD rise time is too long. Failure to ensure that the device is in reset when device voltage is out of specification may cause the device to lock-up and ignore the MCLR pin.
When the Oscillator Start-Up Timer (OST) is enabled (in LF or XT oscillator modes), any interrupt that wakes the processor may cause a WDT reset. This occurs when the WDT is greater than or equal to 50% time-out period when the SLEEP instruction is executed. This will not occur in either the EC or RC oscillator modes. Work-arounds
a)
b)
Always ensure that the CLRWDT instruction is executed before the WDT increments past 50% of the WDT period. This will keep the "false" WDT reset from occurring. When using the WDT as a normal timer (WDT disabled), ensure that the WDT is less than or equal to 50% time-out period when the SLEEP instruction is executed. This can be done by monitoring the TO bit for changing state from set to clear. Example 1 shows putting the PIC17C42 to sleep.
EXAMPLE F-1:
LOOP BTFSS CLRWDT BTFSC GOTO SLEEP
PIC17C42 TO SLEEP
; ; ; ; ; TO = 0? YES, WDT = 0 WDT rollover? NO, Wait YES, goto Sleep
CPUSTA, TO CPUSTA, TO LOOP
2.
When the clock source of Timer1 or Timer2 is selected to external clock, the overflow interrupt flag will be set twice, once when the timer equals the period, and again when the timer value is reset to 0h. If the latency to clear TMRxIF is greater than the time to the next clock pulse, no problems will be noticed. If the latency is less than the time to the next timer clock pulse, the interrupt will be serviced twice. Work-arounds
a) b)
Ensure that the timer has rolled over to 0h before clearing the flag bit. Clear the timer in software. Clearing the timer in software causes the period to be one count less than expected.
(c) 1996 Microchip Technology Inc.
DS30412C-page 223
This document was created with FrameMaker 4 0 4
PIC17C4X
NOTES:
DS30412C-page 224
(c) 1996 Microchip Technology Inc.
PIC17C4X
INDEX
A
ADDLW ............................................................................ 112 ADDWF ............................................................................ 112 ADDWFC ......................................................................... 113 ALU ...................................................................................... 9 ALU STATUS Register (ALUSTA) ..................................... 36 ALUSTA ............................................................... 34, 36, 108 ALUSTA Register ............................................................... 36 ANDLW ............................................................................ 113 ANDWF ............................................................................ 114 Application Notes AN552 ........................................................................ 55 Assembler ........................................................................ 144 Asynchronous Master Transmission .................................. 90 Asynchronous Transmitter ................................................. 89
B
Bank Select Register (BSR) ............................................... 42 Banking .............................................................................. 42 Baud Rate Formula ............................................................ 86 Baud Rate Generator (BRG) .............................................. 86 Baud Rates Asynchronous Mode .................................................. 88 Synchronous Mode .................................................... 87 BCF .................................................................................. 114 Bit Manipulation ............................................................... 108 Block Diagrams On-chip Reset Circuit ................................................. 15 PIC17C42 .................................................................. 10 PORTD ...................................................................... 60 PORTE ....................................................................... 62 PWM .......................................................................... 75 RA0 and RA1 ............................................................. 53 RA2 and RA3 ............................................................. 54 RA4 and RA5 ............................................................. 54 RB3:RB2 Port Pins .................................................... 56 RB7:RB4 and RB1:RB0 Port Pins ............................. 55 RC7:RC0 Port Pins .................................................... 58 Timer3 with One Capture and One Period Register .. 78 TMR1 and TMR2 in 16-bit Timer/Counter Mode ........ 74 TMR1 and TMR2 in Two 8-bit Timer/Counter Mode .. 73 TMR3 with Two Capture Registers ............................ 79 WDT ......................................................................... 104 BORROW ............................................................................ 9 BRG ................................................................................... 86 Brown-out Protection ......................................................... 18 BSF .................................................................................. 115 BSR .............................................................................. 34, 42 BSR Operation ................................................................... 42 BTFSC ............................................................................. 115 BTFSS ............................................................................. 116 BTG .................................................................................. 116
CA1IE .................................................................................23 CA1IF .................................................................................24 CA1OVF .............................................................................72 CA2ED0 ..............................................................................71 CA2ED1 ..............................................................................71 CA2H ............................................................................20, 35 CA2IE ...........................................................................23, 78 CA2IF ...........................................................................24, 78 CA2L .............................................................................20, 35 CA2OVF .............................................................................72 Calculating Baud Rate Error ...............................................86 CALL ...........................................................................39, 117 Capacitor Selection Ceramic Resonators .................................................101 Crystal Oscillator ......................................................101 Capture .........................................................................71, 78 Capture Sequence to Read Example .................................78 Capture1 Mode ...........................................................................71 Overflow .....................................................................72 Capture2 Mode ...........................................................................71 Overflow .....................................................................72 Carry (C) ...............................................................................9 Ceramic Resonators .........................................................100 Circular Buffer .....................................................................39 Clearing the Prescaler ......................................................103 Clock/Instruction Cycle (Figure) .........................................14 Clocking Scheme/Instruction Cycle (Section) .....................14 CLRF ................................................................................117 CLRWDT ..........................................................................118 Code Protection ..........................................................99, 106 COMF ...............................................................................118 Configuration Bits ............................................................................100 Locations ..................................................................100 Oscillator ...................................................................100 Word ...........................................................................99 CPFSEQ ...........................................................................119 CPFSGT ...........................................................................119 CPFSLT ............................................................................120 CPU STATUS Register (CPUSTA) ....................................37 CPUSTA ...............................................................34, 37, 105 CREN .................................................................................84 Crystal Operation, Overtone Crystals ...............................101 Crystal or Ceramic Resonator Operation .........................100 Crystal Oscillator ..............................................................100 CSRC .................................................................................83
D
Data Memory GPR ......................................................................29, 32 Indirect Addressing .....................................................39 Organization ...............................................................32 SFR ......................................................................29, 32 Transfer to Program Memory .....................................43 DAW .................................................................................120 DC ..................................................................................9, 36 DDRB .....................................................................19, 34, 55 DDRC .....................................................................19, 34, 58 DDRD .....................................................................19, 34, 60 DDRE .....................................................................19, 34, 62 DECF ................................................................................121 DECFSNZ .........................................................................122 DECFSZ ...........................................................................121
C
C .................................................................................... 9, 36 C Compiler (MP-C) .......................................................... 145 CA1/PR3 ............................................................................ 72 CA1ED0 ............................................................................. 71 CA1ED1 ............................................................................. 71
(c) 1996 Microchip Technology Inc.
DS30412C-page 225
This document was created with FrameMaker 4 0 4
PIC17C4X
Delay From External Clock Edge ....................................... 68 Development Support ...................................................... 143 Development Tools .......................................................... 143 Device Drawings 44-Lead Plastic Surface Mount (MQFP 10x10 mm Body 1.6/0.15 mm Lead Form) .............. 209 DIGIT BORROW .................................................................. 9 Digit Carry (DC) .................................................................... 9 Duty Cycle .......................................................................... 75 FOSC1 ............................................................................... 99 FS0 .................................................................................... 36 FS1 .................................................................................... 36 FS2 .................................................................................... 36 FS3 .................................................................................... 36 FSR0 ............................................................................ 34, 40 FSR1 ............................................................................ 34, 40 Fuzzy Logic Dev. System (fuzzyTECH(R)-MP) .......... 143, 145
E
Electrical Characteristics PIC17C42 Absolute Maximum Ratings ............................. 147 Capture Timing ................................................ 159 CLKOUT and I/O Timing .................................. 156 DC Characteristics ........................................... 149 External Clock Timing ...................................... 155 Memory Interface Read Timing ........................ 162 Memory Interface Write Timing ........................ 161 PWM Timing .................................................... 159 RESET, Watchdog Timer, Oscillator Start-up Timer and Power-up Timer .............................. 157 Timer0 Clock Timings ...................................... 158 Timer1, Timer2 and Timer3 Clock Timing ........ 158 USART Module, Synchronous Receive ........... 160 USART Module, Synchronous Transmission ... 160 PIC17C43/44 Absolute Maximum Ratings ............................. 175 Capture Timing ................................................ 188 CLKOUT and I/O Timing .................................. 185 DC Characteristics ........................................... 177 External Clock Timing ...................................... 184 Memory Interface Read Timing ........................ 191 Memory Interface Write Timing ........................ 190 Parameter Measurement Information .............. 183 RESET, Watchdog Timer, Oscillator Start-up Timer and Power-up Timer Timing .................. 186 Timer0 Clock Timing ........................................ 187 Timer1, Timer2 and Timer3 Clock Timing ........ 187 Timing Parameter Symbology .......................... 182 USART Module Synchronous Receive Timing .............................................................. 189 USART Module Synchronous Transmission Timing .............................................................. 189 EPROM Memory Access Time Order Suffix ...................... 31 Extended Microcontroller ................................................... 29 Extended Microcontroller Mode ......................................... 31 External Memory Interface ................................................. 31 External Program Memory Waveforms .............................. 31
G
General Format for Instructions ....................................... 108 General Purpose RAM ....................................................... 29 General Purpose RAM Bank ............................................. 42 General Purpose Register (GPR) ...................................... 32 GLINTD .......................................................... 25, 37, 78, 105 GOTO .............................................................................. 122 GPR (General Purpose Register) ...................................... 32 Graphs IOH vs. VOH, VDD = 3V ..................................... 170, 200 IOH vs. VOH, VDD = 5V ..................................... 171, 201 IOL vs. VOL, VDD = 3V ...................................... 171, 201 IOL vs. VOL, VDD = 5V ...................................... 172, 202 Maximum IDD vs. Frequency (External Clock 125C to -40C) ...................... 167, 197 Maximum IPD vs. VDD Watchdog Disabled ...... 168, 198 Maximum IPD vs. VDD Watchdog Enabled ...... 169, 199 RC Oscillator Frequency vs. VDD (Cext = 100 pF) ........................................ 164, 194 RC Oscillator Frequency vs. VDD (Cext = 22 pF) .......................................... 164, 194 RC Oscillator Frequency vs. VDD (Cext = 300 pF) ........................................ 165, 195 Transconductance of LF Oscillator vs.VDD ...... 166, 196 Transconductance of XT Oscillator vs. VDD .... 166, 196 Typical IDD vs. Frequency (External Clock 25C) ...................................... 167, 197 Typical IPD vs. VDD Watchdog Disabled 25C . 168, 198 Typical IPD vs. VDD Watchdog Enabled 25C .. 169, 199 Typical RC Oscillator vs. Temperature ............ 163, 193 VTH (Input Threshold Voltage) of I/O Pins vs. VDD .................................................................. 172, 202 VTH (Input Threshold Voltage) of OSC1 Input (In XT, HS, and LP Modes) vs. VDD ................ 173, 203 VTH, VIL of MCLR, T0CKI and OSC1 (In RC Mode) vs. VDD ...................................... 173, 203 WDT Timer Time-Out Period vs. VDD .............. 170, 200
H
Hardware Multiplier ............................................................ 49
F
Family of Devices ................................................................. 6 PIC14000 .................................................................. 213 PIC16C5X ................................................................ 214 PIC16CXXX .............................................................. 215 PIC16C6X ................................................................ 216 PIC16C7X ................................................................ 217 PIC16C8X ................................................................ 218 PIC16C9XX............................................................... 219 PIC17CXX ................................................................ 220 FERR ........................................................................... 84, 91 FOSC0 ............................................................................... 99
I
I/O Ports Bi-directional .............................................................. 64 I/O Ports .................................................................... 53 Programming Considerations .................................... 64 Read-Modify-Write Instructions ................................. 64 Successive Operations .............................................. 64 INCF ................................................................................ 123 INCFSNZ ......................................................................... 124 INCFSZ ............................................................................ 123 INDF0 .......................................................................... 34, 40 INDF1 .......................................................................... 34, 40
DS30412C-page 226
(c) 1996 Microchip Technology Inc.
PIC17C4X
Indirect Addressing Indirect Addressing .................................................... 39 Operation ................................................................... 40 Registers .................................................................... 40 Initialization Conditions For Special Function Registers .... 19 Initializing PORTB .............................................................. 57 Initializing PORTC .............................................................. 58 Initializing PORTD .............................................................. 60 Initializing PORTE .............................................................. 62 Instruction Flow/Pipelining ................................................. 14 Instruction Set .................................................................. 110 ADDLW .................................................................... 112 ADDWF .................................................................... 112 ADDWFC ................................................................. 113 ANDLW .................................................................... 113 ANDWF .................................................................... 114 BCF .......................................................................... 114 BSF .......................................................................... 115 BTFSC ..................................................................... 115 BTFSS ..................................................................... 116 BTG .......................................................................... 116 CALL ........................................................................ 117 CLRF ........................................................................ 117 CLRWDT .................................................................. 118 COMF ...................................................................... 118 CPFSEQ .................................................................. 119 CPFSGT .................................................................. 119 CPFSLT ................................................................... 120 DAW ......................................................................... 120 DECF ....................................................................... 121 DECFSNZ ................................................................ 122 DECFSZ ................................................................... 121 GOTO ...................................................................... 122 INCF ......................................................................... 123 INCFSNZ ................................................................. 124 INCFSZ .................................................................... 123 IORLW ..................................................................... 124 IORWF ..................................................................... 125 LCALL ...................................................................... 125 MOVFP .................................................................... 126 MOVLB .................................................................... 126 MOVLR .................................................................... 127 MOVLW ................................................................... 127 MOVPF .................................................................... 128 MOVWF ................................................................... 128 MULLW .................................................................... 129 MULWF .................................................................... 129 NEGW ...................................................................... 130 NOP ......................................................................... 130 RETFIE .................................................................... 131 RETLW .................................................................... 131 RETURN .................................................................. 132 RLCF ........................................................................ 132 RLNCF ..................................................................... 133 RRCF ....................................................................... 133 RRNCF .................................................................... 134 SETF ........................................................................ 134 SLEEP ..................................................................... 135 SUBLW .................................................................... 135 SUBWF .................................................................... 136 SUBWFB .................................................................. 136 SWAPF .................................................................... 137 TABLRD ........................................................... 137, 138 TABLWT .......................................................... 138, 139 TLRD ........................................................................ 139 TLWT ....................................................................... 140 TSTFSZ ....................................................................140 XORLW ....................................................................141 XORWF ....................................................................141 Instruction Set Summary ..................................................107 INT Pin ................................................................................26 INTE ...................................................................................22 INTEDG ........................................................................38, 67 Interrupt on Change Feature ..............................................55 Interrupt Status Register (INTSTA) ....................................22 Interrupts Context Saving ...........................................................27 Flag bits TMR1IE ..............................................................21 TMR1IF ..............................................................21 TMR2IE ..............................................................21 TMR2IF ..............................................................21 TMR3IE ..............................................................21 TMR3IF ..............................................................21 Interrupts ....................................................................21 Logic ...........................................................................21 Operation ....................................................................25 Peripheral Interrupt Enable .........................................23 Peripheral Interrupt Request ......................................24 PWM ...........................................................................76 Status Register ...........................................................22 Table Write Interaction ...............................................45 Timing .........................................................................26 Vectors Peripheral Interrupt .............................................26 RA0/INT Interrupt ...............................................26 T0CKI Interrupt ...................................................26 TMR0 Interrupt ...................................................26 Vectors/Priorities ........................................................25 Wake-up from SLEEP ..............................................105 INTF ....................................................................................22 INTSTA ...............................................................................34 INTSTA Register ................................................................22 IORLW ..............................................................................124 IORWF ..............................................................................125
L
LCALL ...............................................................................125 Long Writes ........................................................................45
M
Memory External Interface .......................................................31 External Memory Waveforms .....................................31 Memory Map (Different Modes) ..................................30 Mode Memory Access ................................................30 Organization ...............................................................29 Program Memory ........................................................29 Program Memory Map ................................................29 Microcontroller ....................................................................29 Microprocessor ...................................................................29 Minimizing Current Consumption .....................................106 MOVFP .............................................................................126 MOVLB .............................................................................126 MOVLR .............................................................................127 MOVLW ............................................................................127 MOVPF .............................................................................128 MOVWF ............................................................................128 MPASM Assembler ..................................................143, 144
(c) 1996 Microchip Technology Inc.
DS30412C-page 227
PIC17C4X
MP-C C Compiler ............................................................. 145 MPSIM Software Simulator ...................................... 143, 145 MULLW ............................................................................ 129 Multiply Examples 16 x 16 Routine .......................................................... 50 16 x 16 Signed Routine .............................................. 51 8 x 8 Routine .............................................................. 49 8 x 8 Signed Routine .................................................. 49 MULWF ............................................................................ 129 PORTD .................................................................. 19, 34, 60 PORTE .................................................................. 19, 34, 62 Power-down Mode ........................................................... 105 Power-on Reset (POR) ................................................ 15, 99 Power-up Timer (PWRT) ............................................. 15, 99 PR1 .............................................................................. 20, 35 PR2 .............................................................................. 20, 35 PR3/CA1H ......................................................................... 20 PR3/CA1L .......................................................................... 20 PR3H/CA1H ....................................................................... 35 PR3L/CA1L ........................................................................ 35 Prescaler Assignments ...................................................... 69 PRO MATE(R) Universal Programmer ............................... 143 PRODH .............................................................................. 20 PRODL .............................................................................. 20 Program Counter (PC) ....................................................... 41 Program Memory External Access Waveforms ...................................... 31 External Connection Diagram .................................... 31 Map ............................................................................ 29 Modes Extended Microcontroller ................................... 29 Microcontroller ................................................... 29 Microprocessor .................................................. 29 Protected Microcontroller ................................... 29 Operation ................................................................... 29 Organization .............................................................. 29 Transfers from Data Memory ..................................... 43 Protected Microcontroller ................................................... 29 PS0 .............................................................................. 38, 67 PS1 .............................................................................. 38, 67 PS2 .............................................................................. 38, 67 PS3 .............................................................................. 38, 67 PUSH ........................................................................... 27, 39 PW1DCH ..................................................................... 20, 35 PW1DCL ...................................................................... 20, 35 PW2DCH ..................................................................... 20, 35 PW2DCL ...................................................................... 20, 35 PWM ............................................................................ 71, 75 Duty Cycle ................................................................. 76 External Clock Source ............................................... 76 Frequency vs. Resolution .......................................... 76 Interrupts ................................................................... 76 Max Resolution/Frequency for External Clock Input ................................................................. 77 Output ........................................................................ 75 Periods ...................................................................... 76 PWM1 ................................................................................ 72 PWM1ON ..................................................................... 72, 75 PWM2 ................................................................................ 72 PWM2ON ..................................................................... 72, 75 PWRT .......................................................................... 15, 99
N
NEGW .............................................................................. 130 NOP ................................................................................. 130
O
OERR ................................................................................. 84 Opcode Field Descriptions ............................................... 107 OSC Selection .................................................................... 99 Oscillator Configuration ............................................................ 100 Crystal ...................................................................... 100 External Clock .......................................................... 101 External Crystal Circuit ............................................ 102 External Parallel Resonant Crystal Circuit ............... 102 External Series Resonant Crystal Circuit ................. 102 RC ............................................................................ 102 RC Frequencies ............................................... 165, 195 Oscillator Start-up Time (Figure) ........................................ 18 Oscillator Start-up Timer (OST) ................................... 15, 99 OST .............................................................................. 15, 99 OV .................................................................................. 9, 36 Overflow (OV) ...................................................................... 9
P
Package Marking Information .......................................... 210 Packaging Information ..................................................... 205 Parameter Measurement Information .............................. 154 PC (Program Counter) ....................................................... 41 PCH .................................................................................... 41 PCL ...................................................................... 34, 41, 108 PCLATH ....................................................................... 34, 41 PD .............................................................................. 37, 105 PEIE ............................................................................. 22, 78 PEIF ................................................................................... 22 Peripheral Bank .................................................................. 42 Peripheral Interrupt Enable ................................................ 23 Peripheral Interrupt Request (PIR) ..................................... 24 PICDEM-1 Low-Cost PIC16/17 Demo Board ........... 143, 144 PICDEM-2 Low-Cost PIC16CXX Demo Board ........ 143, 144 PICDEM-3 Low-Cost PIC16C9XXX Demo Board ............ 144 PICMASTER(R) RT In-Circuit Emulator ............................. 143 PICSTART(R) Low-Cost Development System .................. 143 PIE ............................................................. 19, 34, 92, 96, 98 Pin Compatible Devices ................................................... 221 PIR ............................................................. 19, 34, 92, 96, 98 PM0 ............................................................................ 99, 106 PM1 ............................................................................ 99, 106 POP .............................................................................. 27, 39 POR ............................................................................. 15, 99 PORTA ................................................................... 19, 34, 53 PORTB ................................................................... 19, 34, 55 PORTC ................................................................... 19, 34, 58
R
RA1/T0CKI pin ................................................................... 67 RBIE .................................................................................. 23 RBIF ................................................................................... 24 RBPU ................................................................................. 55 RC Oscillator .................................................................... 102 RC Oscillator Frequencies ....................................... 165, 195 RCIE .................................................................................. 23 RCIF .................................................................................. 24 RCREG ................................................ 19, 34, 91, 92, 96, 97 RCSTA ....................................................... 19, 34, 92, 96, 98 Reading 16-bit Value ......................................................... 69
DS30412C-page 228
(c) 1996 Microchip Technology Inc.
PIC17C4X
Receive Status and Control Register ................................. 83 Register File Map ............................................................... 33 Registers ALUSTA ............................................................... 27, 36 BRG ........................................................................... 86 BSR ............................................................................ 27 CPUSTA .................................................................... 37 File Map ..................................................................... 33 FSR0 .......................................................................... 40 FSR1 .......................................................................... 40 INDF0 ......................................................................... 40 INDF1 ......................................................................... 40 INTSTA ...................................................................... 22 PIE ............................................................................. 23 PIR ............................................................................. 24 RCSTA ....................................................................... 84 Special Function Table .............................................. 34 T0STA .................................................................. 38, 67 TCON1 ....................................................................... 71 TCON2 ....................................................................... 72 TMR1 ......................................................................... 81 TMR2 ......................................................................... 81 TMR3 ......................................................................... 81 TXSTA ....................................................................... 83 WREG ........................................................................ 27 Reset Section ....................................................................... 15 Status Bits and Their Significance ............................. 16 Time-Out in Various Situations .................................. 16 Time-Out Sequence ................................................... 16 RETFIE ............................................................................ 131 RETLW ............................................................................ 131 RETURN .......................................................................... 132 RLCF ................................................................................ 132 RLNCF ............................................................................. 133 RRCF ............................................................................... 133 RRNCF ............................................................................ 134 RX Pin Sampling Scheme .................................................. 91 RX9 .................................................................................... 84 RX9D ................................................................................. 84 SWAPF .............................................................................137 SYNC ..................................................................................83 Synchronous Master Mode .................................................93 Synchronous Master Reception .........................................95 Synchronous Master Transmission ....................................93 Synchronous Slave Mode ...................................................97
T
T0CKI Pin ...........................................................................26 T0CKIE ...............................................................................22 T0CKIF ...............................................................................22 T0CS ............................................................................38, 67 T0IE ....................................................................................22 T0IF ....................................................................................22 T0SE .............................................................................38, 67 T0STA ..........................................................................34, 38 T16 .....................................................................................71 Table Latch .........................................................................40 Table Pointer ......................................................................40 Table Read Example ......................................................................48 Section ........................................................................43 Table Reads Section ..................................................48 TABLRD Operation .....................................................44 Timing .........................................................................48 TLRD ..........................................................................48 TLRD Operation .........................................................44 Table Write Code ...........................................................................46 Interaction ...................................................................45 Section ........................................................................43 TABLWT Operation ....................................................43 Terminating Long Writes ............................................45 Timing .........................................................................46 TLWT Operation .........................................................43 To External Memory ...................................................46 To Internal Memory ....................................................45 TABLRD .............................................................44, 137, 138 TABLWT .............................................................43, 138, 139 TBLATH ..............................................................................40 TBLATL ..............................................................................40 TBLPTRH .....................................................................34, 40 TBLPTRL ......................................................................34, 40 TCLK12 ..............................................................................71 TCLK3 ................................................................................71 TCON1 .........................................................................20, 35 TCON2 .........................................................................20, 35 Terminating Long Writes ....................................................45 Time-Out Sequence ...........................................................16 Timer Resources ................................................................65 Timer0 ................................................................................67 Timer1 16-bit Mode .................................................................74 Clock Source Select ...................................................71 On bit ..........................................................................72 Section ..................................................................71, 73 Timer2 16-bit Mode .................................................................74 Clock Source Select ...................................................71 On bit ..........................................................................72 Section ..................................................................71, 73 Timer3 Clock Source Select ...................................................71 On bit ..........................................................................72 Section ..................................................................71, 77
S
Sampling ............................................................................ 91 Saving STATUS and WREG in RAM ................................. 27 SETF ................................................................................ 134 SFR .................................................................................. 108 SFR (Special Function Registers) ................................ 29, 32 SFR As Source/Destination ............................................. 108 Signed Math ......................................................................... 9 SLEEP ............................................................... 99, 105, 135 Software Simulator (MPSIM) ........................................... 145 SPBRG ...................................................... 19, 34, 92, 96, 98 Special Features of the CPU ............................................. 99 Special Function Registers ............................ 29, 32, 34, 108 SPEN ................................................................................. 84 SREN ................................................................................. 84 Stack Operation ................................................................... 39 Pointer ........................................................................ 39 Stack .......................................................................... 29 STKAL ................................................................................ 39 STKAV ............................................................................... 37 SUBLW ............................................................................ 135 SUBWF ............................................................................ 136 SUBWFB .......................................................................... 136
(c) 1996 Microchip Technology Inc.
DS30412C-page 229
PIC17C4X
Timing Diagrams Asynchronous Master Transmission .......................... 90 Asynchronous Reception ........................................... 92 Back to Back Asynchronous Master Transmission .... 90 Interrupt (INT, TMR0 Pins) ......................................... 26 PIC17C42 Capture ................................................... 159 PIC17C42 CLKOUT and I/O .................................... 156 PIC17C42 Memory Interface Read .......................... 162 PIC17C42 Memory Interface Write .......................... 161 PIC17C42 PWM Timing ........................................... 159 PIC17C42 RESET, Watchdog Timer, Oscillator Start-up Timer and Power-up Timer ........................ 157 PIC17C42 Timer0 Clock .......................................... 158 PIC17C42 Timer1, Timer2 and Timer3 Clock .......... 158 PIC17C42 USART Module, Synchronous Receive .................................................................... 160 PIC17C42 USART Module, Synchronous Transmission ............................................................ 160 PIC17C43/44 Capture Timing .................................. 188 PIC17C43/44 CLKOUT and I/O ............................... 185 PIC17C43/44 External Clock ................................... 184 PIC17C43/44 Memory Interface Read ..................... 191 PIC17C43/44 Memory Interface Write ..................... 190 PIC17C43/44 PWM Timing ...................................... 188 PIC17C43/44 RESET, Watchdog Timer, Oscillator Start-up Timer and Power-up Timer ........................ 186 PIC17C43/44 Timer0 Clock ..................................... 187 PIC17C43/44 Timer1, Timer2 and Timer3 Clock ..... 187 PIC17C43/44 USART Module Synchronous Receive .................................................................... 189 PIC17C43/44 USART Module Synchronous Transmission ............................................................ 189 Synchronous Reception ............................................. 95 Synchronous Transmission ........................................ 94 Table Read ................................................................ 48 Table Write ................................................................. 46 TMR0 ................................................................... 68, 69 TMR0 Read/Write in Timer Mode .............................. 70 TMR1, TMR2, and TMR3 in External Clock Mode ..... 80 TMR1, TMR2, and TMR3 in Timer Mode ................... 81 Wake-Up from SLEEP ............................................. 105 Timing Diagrams and Specifications ................................ 155 Timing Parameter Symbology .......................................... 153 TLRD .......................................................................... 44, 139 TLWT ......................................................................... 43, 140 TMR0 16-bit Read ................................................................ 69 16-bit Write ................................................................. 69 Clock Timing ............................................................ 158 Module ....................................................................... 68 Operation ................................................................... 68 Overview .................................................................... 65 Prescaler Assignments .............................................. 69 Read/Write Considerations ........................................ 69 Read/Write in Timer Mode ......................................... 70 Timing .................................................................. 68, 69 TMR0 STATUS/Control Register (T0STA) ......................... 38 TMR0H ............................................................................... 34 TMR0L ............................................................................... 34 TMR1 ........................................................................... 20, 35 8-bit Mode .................................................................. 73 External Clock Input ................................................... 73 Overview .................................................................... 65 Timer Mode ................................................................ 81 Timing in External Clock Mode .................................. 80 Two 8-bit Timer/Counter Mode .................................. 73 Using with PWM ........................................................ 75 TMR1CS ............................................................................ 71 TMR1IE .............................................................................. 23 TMR1IF .............................................................................. 24 TMR1ON ............................................................................ 72 TMR2 ........................................................................... 20, 35 8-bit Mode .................................................................. 73 External Clock Input .................................................. 73 In Timer Mode ........................................................... 81 Timing in External Clock Mode .................................. 80 Two 8-bit Timer/Counter Mode .................................. 73 Using with PWM ........................................................ 75 TMR2CS ............................................................................ 71 TMR2IE .............................................................................. 23 TMR2IF .............................................................................. 24 TMR2ON ............................................................................ 72 TMR3 Dual Capture1 Register Mode ................................... 79 Example, Reading From ............................................ 80 Example, Writing To .................................................. 80 External Clock Input .................................................. 80 In Timer Mode ........................................................... 81 One Capture and One Period Register Mode ........... 78 Overview .................................................................... 65 Reading/Writing ......................................................... 80 Timing in External Clock Mode .................................. 80 TMR3CS ...................................................................... 71, 77 TMR3H ........................................................................ 20, 35 TMR3IE .............................................................................. 23 TMR3IF ........................................................................ 24, 77 TMR3L ......................................................................... 20, 35 TMR3ON ...................................................................... 72, 77 TO ...................................................................... 37, 103, 105 Transmit Status and Control Register ................................ 83 TRMT ................................................................................. 83 TSTFSZ ........................................................................... 140 Turning on 16-bit Timer ..................................................... 74 TX9 .................................................................................... 83 TX9d .................................................................................. 83 TXEN ................................................................................. 83 TXIE ................................................................................... 23 TXIF ................................................................................... 24 TXREG ................................................ 19, 34, 89, 93, 97, 98 TXSTA ....................................................... 19, 34, 92, 96, 98
U
Upward Compatibility ........................................................... 5 USART Asynchronous Master Transmission ......................... 90 Asynchronous Mode .................................................. 89 Asynchronous Receive .............................................. 91 Asynchronous Transmitter ......................................... 89 Baud Rate Generator ................................................ 86 Synchronous Master Mode ........................................ 93 Synchronous Master Reception ................................ 95 Synchronous Master Transmission ........................... 93 Synchronous Slave Mode .......................................... 97 Synchronous Slave Transmit ..................................... 97
W
Wake-up from SLEEP ...................................................... 105 Wake-up from SLEEP Through Interrupt ......................... 105 Watchdog Timer ........................................................ 99, 103
DS30412C-page 230
(c) 1996 Microchip Technology Inc.
PIC17C4X
WDT ........................................................................... 99, 103 Clearing the WDT .................................................... 103 Normal Timer ........................................................... 103 Period ....................................................................... 103 Programming Considerations .................................. 103 WDTPS0 ............................................................................ 99 WDTPS1 ............................................................................ 99 WREG ................................................................................ 34
LIST OF EXAMPLES
Example 3-1: Example 3-2: Example 5-1: Example 6-1: Example 7-1: Example 7-2: Example 8-1: Example 8-2: Example 8-3: Example 8-4: Example 9-1: Example 9-2: Example 9-3: Example 9-4: Example 9-5: Example 11-1: Example 11-2: Example 12-1: Example 12-2: Example 12-3: Example 13-1: Example F-1: Signed Math ..................................................9 Instruction Pipeline Flow .............................14 Saving STATUS and WREG in RAM ..........27 Indirect Addressing......................................40 Table Write ..................................................46 Table Read..................................................48 8 x 8 Multiply Routine ..................................49 8 x 8 Signed Multiply Routine......................49 16 x 16 Multiply Routine ..............................50 16 x 16 Signed Multiply Routine..................51 Initializing PORTB .......................................57 Initializing PORTC .......................................58 Initializing PORTD .......................................60 Initializing PORTE .......................................62 Read Modify Write Instructions on an I/O Port ........................................................64 16-Bit Read .................................................69 16-Bit Write..................................................69 Sequence to Read Capture Registers.........78 Writing to TMR3 ..........................................80 Reading from TMR3 ....................................80 Calculating Baud Rate Error........................86 PIC17C42 to Sleep....................................223
X
XORLW ............................................................................ 141 XORWF ............................................................................ 141
Z
Z ..................................................................................... 9, 36 Zero (Z) ................................................................................ 9
LIST OF FIGURES
Figure 3-1: Figure 3-2: Figure 3-3: Figure 4-1: Figure 4-2: Figure 4-3: Figure 4-4: Figure 4-5: Figure 4-6: Figure 4-7: Figure 4-8: Figure 4-9: Figure 5-1: Figure 5-2: Figure 5-3: Figure 5-4: Figure 5-5: Figure 6-1: Figure 6-2: Figure 6-3: Figure 6-4: Figure 6-5: Figure 6-6: Figure 6-7: Figure 6-8: Figure 6-9: Figure 6-10: Figure 6-11: PIC17C42 Block Diagram ...........................10 PIC17CR42/42A/43/R43/44 Block Diagram.......................................................11 Clock/Instruction Cycle................................14 Simplified Block Diagram of On-chip Reset Circuit................................................15 Time-Out Sequence on Power-Up (MCLR Tied to VDD) ....................................17 Time-Out Sequence on Power-Up (MCLR NOT Tied to VDD)............................17 Slow Rise Time (MCLR Tied to VDD) ..........17 Oscillator Start-Up Time ..............................18 Using On-Chip POR ....................................18 Brown-out Protection Circuit 1.....................18 PIC17C42 External Power-On Reset Circuit (For Slow VDD Power-Up) ................18 Brown-out Protection Circuit 2.....................18 Interrupt Logic .............................................21 INTSTA Register (Address: 07h, Unbanked)...................................................22 PIE Register (Address: 17h, Bank 1) ..........23 PIR Register (Address: 16h, Bank 1) ..........24 INT Pin / T0CKI Pin Interrupt Timing...........26 Program Memory Map and Stack................29 Memory Map in Different Modes .................30 External Program Memory Access Waveforms ..................................................31 Typical External Program Memory Connection Diagram....................................31 PIC17C42 Register File Map.......................33 PIC17CR42/42A/43/R43/44 Register File Map.......................................................33 ALUSTA Register (Address: 04h, Unbanked)...................................................36 CPUSTA Register (Address: 06h, Unbanked)...................................................37 T0STA Register (Address: 05h, Unbanked)...................................................38 Indirect Addressing......................................39 Program Counter Operation ........................41
(c) 1996 Microchip Technology Inc.
DS30412C-page 231
PIC17C4X
Program Counter using The CALL and GOTO Instructions...................................... 41 Figure 6-13: BSR Operation (PIC17C43/R43/44) ........... 42 Figure 7-1: TLWT Instruction Operation........................ 43 Figure 7-2: TABLWT Instruction Operation................... 43 Figure 7-3: TLRD Instruction Operation ........................ 44 Figure 7-4: TABLRD Instruction Operation ................... 44 Figure 7-5: TABLWT Write Timing (External Memory) ...................................... 46 Figure 7-6: Consecutive TABLWT Write Timing (External Memory) ...................................... 47 Figure 7-7: TABLRD Timing.......................................... 48 Figure 7-8: TABLRD Timing (Consecutive TABLRD Instructions) ................................................ 48 Figure 9-1: RA0 and RA1 Block Diagram ..................... 53 Figure 9-2: RA2 and RA3 Block Diagram ..................... 54 Figure 9-3: RA4 and RA5 Block Diagram ..................... 54 Figure 9-4: Block Diagram of RB<7:4> and RB<1:0> Port Pins ..................................................... 55 Figure 9-5: Block Diagram of RB3 and RB2 Port Pins.. 56 Figure 9-6: Block Diagram of RC<7:0> Port Pins ......... 58 Figure 9-7: PORTD Block Diagram (in I/O Port Mode) ....................................... 60 Figure 9-8: PORTE Block Diagram (in I/O Port Mode) ....................................... 62 Figure 9-9: Successive I/O Operation ........................... 64 Figure 11-1: T0STA Register (Address: 05h, Unbanked) .................................................. 67 Figure 11-2: Timer0 Module Block Diagram ................... 68 Figure 11-3: TMR0 Timing with External Clock (Increment on Falling Edge) ....................... 68 Figure 11-4: TMR0 Timing: Write High or Low Byte ....... 69 Figure 11-5: TMR0 Read/Write in Timer Mode ............... 70 Figure 12-1: TCON1 Register (Address: 16h, Bank 3) ... 71 Figure 12-2: TCON2 Register (Address: 17h, Bank 3) ... 72 Figure 12-3: Timer1 and Timer2 in Two 8-bit Timer/Counter Mode................................... 73 Figure 12-4: TMR1 and TMR2 in 16-bit Timer/Counter Mode........................................................... 74 Figure 12-5: Simplified PWM Block Diagram .................. 75 Figure 12-6: PWM Output ............................................... 75 Figure 12-7: Timer3 with One Capture and One Period Register Block Diagram................... 78 Figure 12-8: Timer3 with Two Capture Registers Block Diagram ............................................ 79 Figure 12-9: TMR1, TMR2, and TMR3 Operation in External Clock Mode................................... 80 Figure 12-10: TMR1, TMR2, and TMR3 Operation in Timer Mode................................................. 81 Figure 13-1: TXSTA Register (Address: 15h, Bank 0) .... 83 Figure 13-2: RCSTA Register (Address: 13h, Bank 0) ... 84 Figure 13-3: USART Transmit......................................... 85 Figure 13-4: USART Receive.......................................... 85 Figure 13-5: Asynchronous Master Transmission........... 90 Figure 13-6: Asynchronous Master Transmission (Back to Back) ............................................ 90 Figure 13-7: RX Pin Sampling Scheme .......................... 91 Figure 13-8: Asynchronous Reception............................ 92 Figure 13-9: Synchronous Transmission ........................ 94 Figure 13-10: Synchronous Transmission (Through TXEN) ......................................... 94 Figure 13-11: Synchronous Reception (Master Mode, SREN)......................................................... 95 Figure 14-1: Configuration Word..................................... 99 Figure 14-2: Crystal or Ceramic Resonator Operation (XT or LF OSC Configuration) .................. 100 Figure 6-12: Figure 14-3: Figure 14-4: Figure 14-5: Figure 14-6: Figure 14-7: Figure 14-8: Figure 14-9: Figure 15-1: Figure 15-2: Figure 17-1: Figure 17-2: Figure 17-3: Figure 17-4: Crystal Operation, Overtone Crystals (XT OSC Configuration) ........................... 101 External Clock Input Operation (EC OSC Configuration)........................... 101 External Parallel Resonant Crystal Oscillator Circuit ....................................... 102 External Series Resonant Crystal Oscillator Circuit ....................................... 102 RC Oscillator Mode .................................. 102 Watchdog Timer Block Diagram............... 104 Wake-up From Sleep Through Interrupt... 105 General Format for Instructions................ 108 Q Cycle Activity ........................................ 109 Parameter Measurement Information....... 154 External Clock Timing .............................. 155 CLKOUT and I/O Timing .......................... 156 Reset, Watchdog Timer, Oscillator Start-Up Timer and Power-Up Timer Timing ........................... 157 Timer0 Clock Timings............................... 158 Timer1, Timer2, And Timer3 Clock Timings..................................................... 158 Capture Timings ....................................... 159 PWM Timings ........................................... 159 USART Module: Synchronous Transmission (Master/Slave) Timing ........ 160 USART Module: Synchronous Receive (Master/Slave) Timing .............................. 160 Memory Interface Write Timing ................ 161 Memory Interface Read Timing ................ 162 Typical RC Oscillator Frequency vs. Temperature ....................................... 163 Typical RC Oscillator Frequency vs. VDD ..................................................... 164 Typical RC Oscillator Frequency vs. VDD ..................................................... 164 Typical RC Oscillator Frequency vs. VDD ..................................................... 165 Transconductance (gm) of LF Oscillator vs. VDD ..................................................... 166 Transconductance (gm) of XT Oscillator vs. VDD ..................................................... 166 Typical IDD vs. Frequency (External Clock 25C) .............................................. 167 Maximum IDD vs. Frequency (External Clock 125C to -40C) .............................. 167 Typical IPD vs. VDD Watchdog Disabled 25C .......................................... 168 Maximum IPD vs. VDD Watchdog Disabled ................................................... 168 Typical IPD vs. VDD Watchdog Enabled 25C ........................................... 169 Maximum IPD vs. VDD Watchdog Enabled .................................................... 169 WDT Timer Time-Out Period vs. VDD ...... 170 IOH vs. VOH, VDD = 3V.............................. 170 IOH vs. VOH, VDD = 5V.............................. 171 IOL vs. VOL, VDD = 3V............................... 171 IOL vs. VOL, VDD = 5V............................... 172 VTH (Input Threshold Voltage) of I/O Pins (TTL) VS. VDD ............................. 172 VTH, VIL of I/O Pins (Schmitt Trigger) VS. VDD ........................................................... 173 VTH (Input Threshold Voltage) of OSC1 Input (In XT and LF Modes) vs. VDD ........ 173 Parameter Measurement Information....... 183
Figure 17-5: Figure 17-6: Figure 17-7: Figure 17-8: Figure 17-9: Figure 17-10: Figure 17-11: Figure 17-12: Figure 18-1: Figure 18-2: Figure 18-3: Figure 18-4: Figure 18-5: Figure 18-6: Figure 18-7: Figure 18-8: Figure 18-9: Figure 18-10: Figure 18-11: Figure 18-12: Figure 18-13: Figure 18-14: Figure 18-15: Figure 18-16: Figure 18-17: Figure 18-18: Figure 18-19: Figure 18-20: Figure 19-1:
DS30412C-page 232
(c) 1996 Microchip Technology Inc.
PIC17C4X
Figure 19-2: Figure 19-3: Figure 19-4: External Clock Timing............................... 184 CLKOUT and I/O Timing........................... 185 Reset, Watchdog Timer, Oscillator Start-Up Timer, and Power-Up Timer Timing............................ 186 Timer0 Clock Timings ............................... 187 Timer1, Timer2, and Timer3 Clock Timings ..................................................... 187 Capture Timings ....................................... 188 PWM Timings ........................................... 188 USART Module: Synchronous Transmission (Master/Slave) Timing ........ 189 USART Module: Synchronous Receive (Master/Slave) Timing................. 189 Memory Interface Write Timing (Not Supported in PIC17LC4X Devices)... 190 Memory Interface Read Timing (Not Supported in PIC17LC4X Devices)... 191 Typical RC Oscillator Frequency vs. Temperature ............................................. 193 Typical RC Oscillator Frequency vs. VDD...................................................... 194 Typical RC Oscillator Frequency vs. VDD...................................................... 194 Typical RC Oscillator Frequency vs. VDD...................................................... 195 Transconductance (gm) of LF Oscillator vs. VDD...................................................... 196 Transconductance (gm) of XT Oscillator vs. VDD...................................................... 196 Typical IDD vs. Frequency (External Clock 25C)............................................... 197 Maximum IDD vs. Frequency (External Clock 125C to -40C) .............................. 197 Typical IPD vs. VDD Watchdog Disabled 25C........................................... 198 Maximum IPD vs. VDD Watchdog Disabled.................................................... 198 Typical IPD vs. VDD Watchdog Enabled 25C............................................ 199 Maximum IPD vs. VDD Watchdog Enabled..................................................... 199 WDT Timer Time-Out Period vs. VDD....... 200 IOH vs. VOH, VDD = 3V .............................. 200 IOH vs. VOH, VDD = 5V .............................. 201 IOL vs. VOL, VDD = 3V ............................... 201 IOL vs. VOL, VDD = 5V ............................... 202 VTH (Input Threshold Voltage) of I/O Pins (TTL) VS. VDD.............................. 202 VTH, VIL of I/O Pins (Schmitt Trigger) VS. VDD ..................................................... 203 VTH (Input Threshold Voltage) of OSC1 Input (In XT and LF Modes) vs. VDD........ 203 Table 6-2: Table 6-3: Table 7-1: Table 8-1: Table 9-1: Table 9-2: Table 9-3: Table 9-4: Table 9-5: Table 9-6: Table 9-7: Table 9-8: Table 9-9: Table 9-10: Table 11-1: Table 12-1: Table 12-2: Table 12-3: Table 12-4: Table 12-5: Table 12-6: Table 13-1: Table 13-2: Table 13-3: Table 13-4: Table 13-5: Table 13-6: Table 13-7: Table 13-8: Table 13-9: Table 13-10: Table 14-1: Table 14-2: Table 14-3: Table 14-4: Table 15-1: Table 15-2: Table 16-1: Table 17-1: EPROM Memory Access Time Ordering Suffix ............................................31 Special Function Registers..........................34 Interrupt - Table Write Interaction................45 Performance Comparison ...........................49 PORTA Functions .......................................54 Registers/Bits Associated with PORTA.......54 PORTB Functions .......................................57 Registers/Bits Associated with PORTB.......57 PORTC Functions .......................................59 Registers/Bits Associated with PORTC.......59 PORTD Functions .......................................61 Registers/Bits Associated with PORTD.......61 PORTE Functions .......................................63 Registers/Bits Associated with PORTE.......63 Registers/Bits Associated with Timer0 ........70 Turning On 16-bit Timer ..............................74 Summary of Timer1 and Timer2 Registers .....................................................74 PWM Frequency vs. Resolution at 25 MHz ........................................................76 Registers/Bits Associated with PWM ..........77 Registers Associated with Capture .............79 Summary of TMR1, TMR2, and TMR3 Registers .....................................................81 Baud Rate Formula .....................................86 Registers Associated with Baud Rate Generator ....................................................86 Baud Rates for Synchronous Mode ............87 Baud Rates for Asynchronous Mode...........88 Registers Associated with Asynchronous Transmission ...............................................90 Registers Associated with Asynchronous Reception ....................................................92 Registers Associated with Synchronous Master Transmission ...................................94 Registers Associated with Synchronous Master Reception ........................................96 Registers Associated with Synchronous Slave Transmission .....................................98 Registers Associated with Synchronous Slave Reception ..........................................98 Configuration Locations.............................100 Capacitor Selection for Ceramic Resonators ................................................101 Capacitor Selection for Crystal OscillatoR ..................................................101 Registers/Bits Associated with the Watchdog Timer ........................................104 Opcode Field Descriptions ........................107 PIC17CXX Instruction Set .........................110 development tools from microchip.............146 Cross Reference of Device Specs for Oscillator Configurations and Frequencies of Operation (Commercial Devices) ..........148 External Clock Timing Requirements ........155 CLKOUT and I/O Timing Requirements....156 Reset, Watchdog Timer, Oscillator Start-Up Timer and Power-Up Timer Requirements.................157 Timer0 Clock Requirements......................158 Timer1, Timer2, and Timer3 Clock Requirements ............................................158 Capture Requirements ..............................159 PWM Requirements ..................................159
Figure 19-5: Figure 19-6: Figure 19-7: Figure 19-8: Figure 19-9: Figure 19-10: Figure 19-11: Figure 19-12: Figure 20-1: Figure 20-2: Figure 20-3: Figure 20-4: Figure 20-5: Figure 20-6: Figure 20-7: Figure 20-8: Figure 20-9: Figure 20-10: Figure 20-11: Figure 20-12: Figure 20-13: Figure 20-14: Figure 20-15: Figure 20-16: Figure 20-17: Figure 20-18: Figure 20-19: Figure 20-20:
LIST OF TABLES
Table 1-1: Table 3-1: Table 4-1: Table 4-2: Table 4-3: Table 4-4: Table 5-1: Table 6-1: PIC17CXX Family of Devices ....................... 6 Pinout Descriptions..................................... 12 Time-Out in Various Situations ................... 16 STATUS Bits and Their Significance .......... 16 Reset Condition for the Program Counter and the CPUSTA Register.......................... 16 Initialization Conditions For Special Function Registers...................................... 19 Interrupt Vectors/Priorities .......................... 25 Mode Memory Access ................................ 30 Table 17-2: Table 17-3: Table 17-4:
Table 17-5: Table 17-6: Table 17-7: Table 17-8:
(c) 1996 Microchip Technology Inc.
DS30412C-page 233
PIC17C4X
Table 17-9: Table 17-10: Table 17-11: Table 17-12: Table 18-1: Table 18-2: Table 19-1: Serial Port Synchronous Transmission Requirements ........................................... 160 Serial Port Synchronous Receive Requirements ........................................... 160 Memory Interface Write Requirements ..... 161 Memory Interface Read Requirements..... 162 Pin Capacitance per Package Type ......... 163 RC Oscillator Frequencies........................ 165 Cross Reference of Device Specs for Oscillator Configurations and Frequencies of Operation (Commercial Devices).......... 176 External Clock Timing Requirements ....... 184 CLKOUT and I/O Timing Requirements ... 185 Reset, Watchdog Timer, Oscillator Start-Up Timer and Power-Up Timer Requirements ................ 186 Timer0 Clock Requirements ..................... 187 Timer1, Timer2, and Timer3 Clock Requirements ........................................... 187 Capture Requirements.............................. 188 PWM Requirements.................................. 188 Synchronous Transmission Requirements ........................................... 189 Synchronous Receive Requirements ....... 189 Memory Interface Write Requirements (Not Supported in PIC17LC4X Devices)... 190 Memory Interface read Requirements (Not Supported in PIC17LC4X Devices)... 191 Pin Capacitance per Package Type ......... 193 RC Oscillator Frequencies........................ 195 Pin Compatible Devices............................ 221
Table 19-2: Table 19-3: Table 19-4:
Table 19-5: Table 19-6: Table 19-7: Table 19-8: Table 19-9: Table 19-10: Table 19-11: Table 19-12: Table 20-1: Table 20-2: Table E-1:
LIST OF EQUATIONS
Equation 8-1: 16 x 16 Unsigned Multiplication Algorithm..................................................... 50 Equation 8-2: 16 x 16 Signed Multiplication Algorithm..................................................... 51
DS30412C-page 234
(c) 1996 Microchip Technology Inc.
PIC17C4X
ON-LINE SUPPORT
Microchip provides two methods of on-line support. These are the Microchip BBS and the Microchip World Wide Web (WWW) site. Use Microchip's Bulletin Board Service (BBS) to get current information and help about Microchip products. Microchip provides the BBS communication channel for you to use in extending your technical staff with microcontroller and memory experts. To provide you with the most responsive service possible, the Microchip systems team monitors the BBS, posts the latest component data and software tool updates, provides technical help and embedded systems insights, and discusses how Microchip products provide project solutions. The web site, like the BBS, is used by Microchip as a means to make files and information easily available to customers. To view the site, the user must have access to the Internet and a web browser, such as Netscape or Microsoft Explorer. Files are also available for FTP download from our FTP site. The procedure to connect will vary slightly from country to country. Please check with your local CompuServe agent for details if you have a problem. CompuServe service allow multiple users various baud rates depending on the local point of access. The following connect procedure applies in most locations. 1. Set your modem to 8-bit, No parity, and One stop (8N1). This is not the normal CompuServe setting which is 7E1. 2. Dial your local CompuServe access number. 3. Depress the key and a garbage string will appear because CompuServe is expecting a 7E1 setting. 4. Type +, depress the key and "Host Name:" will appear. 5. Type MCHIPBBS, depress the key and you will be connected to the Microchip BBS. In the United States, to find the CompuServe phone number closest to you, set your modem to 7E1 and dial (800) 848-4480 for 300-2400 baud or (800) 331-7166 for 9600-14400 baud connection. After the system responds with "Host Name:", type NETWORK, depress the key and follow CompuServe's directions. For voice information (or calling from overseas), you may call (614) 723-1550 for your local CompuServe number. Microchip regularly uses the Microchip BBS to distribute technical information, application notes, source code, errata sheets, bug reports, and interim patches for Microchip systems software products. For each SIG, a moderator monitors, scans, and approves or disapproves files submitted to the SIG. No executable files are accepted from the user community in general to limit the spread of computer viruses.
Connecting to the Microchip Internet Web Site
The Microchip web site is available by using your favorite Internet browser to attach to: www.microchip.com The file transfer site is available by using an FTP service to connect to: ftp.mchip.com/biz/mchip The web site and file transfer site provide a variety of services. Users may download files for the latest Development Tools, Data Sheets, Application Notes, User's Guides, Articles and Sample Programs. A variety of Microchip specific business information is also available, including listings of Microchip sales offices, distributors and factory representatives. Other data available for consideration is: * Latest Microchip Press Releases * Technical Support Section with Frequently Asked Questions * Design Tips * Device Errata * Job Postings * Microchip Consultant Program Member Listing * Links to other useful web sites related to Microchip Products
Systems Information and Upgrade Hot Line
The Systems Information and Upgrade Line provides system users a listing of the latest versions of all of Microchip's development systems software products. Plus, this line provides information on how customers can receive any currently available upgrade kits.The Hot Line Numbers are: 1-800-755-2345 for U.S. and most of Canada, and 1-602-786-7302 for the rest of the world.
960513
Connecting to the Microchip BBS
Connect worldwide to the Microchip BBS using either the Internet or the CompuServe(R) communications network.
Internet:
You can telnet or ftp to the Microchip BBS at the address: mchipbbs.microchip.com
Trademarks: The Microchip name, logo, PIC, PICSTART, PICMASTER and PRO MATE are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. FlexROM, MPLAB and fuzzyLAB, are trademarks and SQTP is a service mark of Microchip in the U.S.A. fuzzyTECH is a registered trademark of Inform Software Corporation. IBM, IBM PC-AT are registered trademarks of International Business Machines Corp. Pentium is a trademark of Intel Corporation. Windows is a trademark and MS-DOS, Microsoft Windows are registered trademarks of Microsoft Corporation. CompuServe is a registered trademark of CompuServe Incorporated. All other trademarks mentioned herein are the property of their respective companies.
CompuServe Communications Network:
When using the BBS via the Compuserve Network, in most cases, a local call is your only expense. The Microchip BBS connection does not use CompuServe membership services, therefore you do not need CompuServe membership to join Microchip's BBS. There is no charge for connecting to the Microchip BBS.
(c) 1996 Microchip Technology Inc.
DS30412C-page 235
This document was created with FrameMaker 4 0 4
PIC17C4X
READER RESPONSE
It is our intention to provide you with the best documentation possible to ensure successful use of your Microchip product. If you wish to provide your comments on organization, clarity, subject matter, and ways in which our documentation can better serve you, please FAX your comments to the Technical Publications Manager at (602) 786-7578. Please list the following information, and use this outline to provide us with your comments about this Data Sheet. To: RE: Technical Publications Manager Reader Response Total Pages Sent
From: Name Company Address City / State / ZIP / Country Telephone: (_______) _________ - _________ Application (optional): Would you like a reply? Device: PIC17C4X Questions: 1. What are the best features of this document? Y N Literature Number: DS30412C FAX: (______) _________ - _________
2. How does this document meet your hardware and software development needs?
3. Do you find the organization of this data sheet easy to follow? If not, why?
4. What additions to the data sheet do you think would enhance the structure and subject?
5. What deletions from the data sheet could be made without affecting the overall usefulness?
6. Is there any incorrect or misleading information (what and where)?
7. How would you improve this document?
8. How would you improve our software, systems, and silicon products?
DS30412C-page 236
(c) 1996 Microchip Technology Inc.
PIC17C4X
PIC17C4X Product Identification System
To order or to obtain information, e.g., on pricing or delivery, please use the listed part numbers, and refer to the factory or the listed sales offices.
PART NO. - XX X /XX XXX
Pattern: QTP, SQTP, ROM Code (factory specified) or Special Requirements. Blank for OTP and Windowed devices P = PDIP JW = Windowed CERDIP P = PDIP (600 mil) PQ = MQFP PT = TQFP L = PLCC - = 0C to +70C I = -40C to +85C 08 = 8 MHz 16 = 16 MHz 25 = 25 Mhz 33 = 33 Mhz PIC17C44 : Standard Vdd range PIC17C44T : (Tape and Reel) PIC17LC44 : Extended Vdd range
Examples
a)
PIC17C42 - 16/P Commercial Temp., PDIP package, 16 MHZ, normal VDD limits PIC17LC44 - 08/PT Commercial Temp., TQFP package, 8MHz, extended VDD limits PIC17C43 - 25I/P Industrial Temp., PDIP package, 25 MHz, normal VDD limits
Package:
b)
Temperature Range: Frequency Range: Device:
c)
Sales and Support
Products supported by a preliminary Data Sheet may possibly have an errata sheet describing minor operational differences and recommended workarounds. To determine if an errata sheet exists for a particular device, please contact one of the following: 1.Your local Microchip sales office (see below) 2.The Microchip Corporate Literature Center U.S. FAX: (602) 786-7277
3.The Microchip's Bulletin Board, via your local CompuServe number (CompuServe membership NOT required).
Please specify which device, revision of silicon and Data Sheet (include Literature #) you are using. For latest version information and upgrade kits for Microchip Development Tools, please call 1-800-755-2345 or 1-602-786-7302.
(c) 1996 Microchip Technology Inc.
DS30412C-page 237
This document was created with FrameMaker 4 0 4
PIC17C4X
NOTES:
DS30412C-page 238
(c) 1996 Microchip Technology Inc.
PIC17C4X
NOTES:
DS30412C-page 239
(c) 1996 Microchip Technology Inc.
WORLDWIDE SALES AND SERVICE
AMERICAS
Corporate Office
Microchip Technology Inc. 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-786-7200 Fax: 480-786-7277 Technical Support: 480-786-7627 Web Address: http://www.microchip.com
AMERICAS (continued)
Toronto
Microchip Technology Inc. 5925 Airport Road, Suite 200 Mississauga, Ontario L4V 1W1, Canada Tel: 905-405-6279 Fax: 905-405-6253
ASIA/PACIFIC (continued)
Singapore
Microchip Technology Singapore Pte Ltd. 200 Middle Road #07-02 Prime Centre Singapore 188980 Tel: 65-334-8870 Fax: 65-334-8850
ASIA/PACIFIC
Hong Kong
Microchip Asia Pacific Unit 2101, Tower 2 Metroplaza 223 Hing Fong Road Kwai Fong, N.T., Hong Kong Tel: 852-2-401-1200 Fax: 852-2-401-3431
Taiwan, R.O.C
Microchip Technology Taiwan 10F-1C 207 Tung Hua North Road Taipei, Taiwan, ROC Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
Atlanta
Microchip Technology Inc. 500 Sugar Mill Road, Suite 200B Atlanta, GA 30350 Tel: 770-640-0034 Fax: 770-640-0307
Boston
Microchip Technology Inc. 5 Mount Royal Avenue Marlborough, MA 01752 Tel: 508-480-9990 Fax: 508-480-8575
EUROPE
United Kingdom
Arizona Microchip Technology Ltd. 505 Eskdale Road Winnersh Triangle Wokingham Berkshire, England RG41 5TU Tel: 44 118 921 5858 Fax: 44-118 921-5835
Beijing
Microchip Technology, Beijing Unit 915, 6 Chaoyangmen Bei Dajie Dong Erhuan Road, Dongcheng District New China Hong Kong Manhattan Building Beijing 100027 PRC Tel: 86-10-85282100 Fax: 86-10-85282104
Chicago
Microchip Technology Inc. 333 Pierce Road, Suite 180 Itasca, IL 60143 Tel: 630-285-0071 Fax: 630-285-0075
India
Microchip Technology Inc. India Liaison Office No. 6, Legacy, Convent Road Bangalore 560 025, India Tel: 91-80-229-0061 Fax: 91-80-229-0062
Denmark
Microchip Technology Denmark ApS Regus Business Centre Lautrup hoj 1-3 Ballerup DK-2750 Denmark Tel: 45 4420 9895 Fax: 45 4420 9910
Dallas
Microchip Technology Inc. 4570 Westgrove Drive, Suite 160 Addison, TX 75248 Tel: 972-818-7423 Fax: 972-818-2924
Japan
Microchip Technology Intl. Inc. Benex S-1 6F 3-18-20, Shinyokohama Kohoku-Ku, Yokohama-shi Kanagawa 222-0033 Japan Tel: 81-45-471- 6166 Fax: 81-45-471-6122
France
Arizona Microchip Technology SARL Parc d'Activite du Moulin de Massy 43 Rue du Saule Trapu Batiment A - ler Etage 91300 Massy, France Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79
Dayton
Microchip Technology Inc. Two Prestige Place, Suite 150 Miamisburg, OH 45342 Tel: 937-291-1654 Fax: 937-291-9175
Detroit
Microchip Technology Inc. Tri-Atria Office Building 32255 Northwestern Highway, Suite 190 Farmington Hills, MI 48334 Tel: 248-538-2250 Fax: 248-538-2260
Korea
Microchip Technology Korea 168-1, Youngbo Bldg. 3 Floor Samsung-Dong, Kangnam-Ku Seoul, Korea Tel: 82-2-554-7200 Fax: 82-2-558-5934
Germany
Arizona Microchip Technology GmbH Gustav-Heinemann-Ring 125 D-81739 Munchen, Germany Tel: 49-89-627-144 0 Fax: 49-89-627-144-44
Los Angeles
Microchip Technology Inc. 18201 Von Karman, Suite 1090 Irvine, CA 92612 Tel: 949-263-1888 Fax: 949-263-1338
Italy
Arizona Microchip Technology SRL Centro Direzionale Colleoni Palazzo Taurus 1 V. Le Colleoni 1 20041 Agrate Brianza Milan, Italy Tel: 39-039-65791-1 Fax: 39-039-6899883
11/15/99
Shanghai
Microchip Technology RM 406 Shanghai Golden Bridge Bldg. 2077 Yan'an Road West, Hong Qiao District Shanghai, PRC 200335 Tel: 86-21-6275-5700 Fax: 86 21-6275-5060
New York
Microchip Technology Inc. 150 Motor Parkway, Suite 202 Hauppauge, NY 11788 Tel: 631-273-5305 Fax: 631-273-5335
San Jose
Microchip Technology Inc. 2107 North First Street, Suite 590 San Jose, CA 95131 Tel: 408-436-7950 Fax: 408-436-7955
Microchip received QS-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona in July 1999. The Company's quality system processes and procedures are QS-9000 compliant for its PICmicro(R) 8-bit MCUs, KEELOQ(R) code hopping devices, Serial EEPROMs and microperipheral products. In addition, Microchip's quality system for the design and manufacture of development systems is ISO 9001 certified.
All rights reserved. (c) 1999 Microchip Technology Incorporated. Printed in the USA. 11/99
Printed on recycled paper.
Information contained in this publication regarding device applications and the like is intended for suggestion only and may be superseded by updates. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. Use of Microchip's products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any intellectual property rights. The Microchip logo and name are registered trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All rights reserved. All other trademarks mentioned herein are the property of their respective companies.
1999 Microchip Technology Inc.


▲Up To Search▲   

 
Price & Availability of PIC17LC42-33IL

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X